This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
сервис_ansible [2024/12/05 17:38] val [Настройка групп управляемых систем] |
сервис_ansible [2025/03/15 16:44] (current) val [Использование модулей] |
||
---|---|---|---|
Line 108: | Line 108: | ||
node1# ansible all -m ping | node1# ansible all -m ping | ||
node1# ansible all -m ping -i inv_file.ini | node1# ansible all -m ping -i inv_file.ini | ||
- | node1# ansible all -m ping -i node2:2222, -e "ansible_python_interpreter=/usr/bin/python3" | + | node1# ansible all -m ping -i node2:2222, |
node1# ansible corpX -m command -a 'uname -a' | node1# ansible corpX -m command -a 'uname -a' | ||
- | kube1# ansible kubes -a 'sed -i"" -e "/swap/s/^/#/" /etc/fstab' | ||
- | kube1# ansible kubes -a 'swapoff -a' | ||
- | ИЛИ | ||
(venv1) server# ansible all -a 'sed -i"" -e "/swap/s/^/#/" /etc/fstab' -i /root/kubespray/inventory/mycluster/hosts.yaml #--limit=kube4,kube5 | (venv1) server# ansible all -a 'sed -i"" -e "/swap/s/^/#/" /etc/fstab' -i /root/kubespray/inventory/mycluster/hosts.yaml #--limit=kube4,kube5 | ||
(venv1) server# ansible all -a 'swapoff -a' -i /root/kubespray/inventory/mycluster/hosts.yaml #--limit=kube4 | (venv1) server# ansible all -a 'swapoff -a' -i /root/kubespray/inventory/mycluster/hosts.yaml #--limit=kube4 | ||
Line 316: | Line 313: | ||
<code> | <code> | ||
node1# ansible -m setup corpX | node1# ansible -m setup corpX | ||
+ | |||
+ | server# ansible all -m setup -i gate, | ||
node1# ansible -m setup corpX | grep ansible_fqdn | node1# ansible -m setup corpX | grep ansible_fqdn | ||
Line 329: | Line 328: | ||
</html> | </html> | ||
</code><code> | </code><code> | ||
- | node1# cat inst_apache.yml | + | node1# cat inst_http.yml |
</code><code> | </code><code> | ||
- hosts: corpX | - hosts: corpX | ||
+ | #- hosts: all | ||
+ | |||
tasks: | tasks: | ||
- | - name: Installs apache web server | + | - name: Install or remove web server |
apt: pkg=apache2 state=present update_cache=true | apt: pkg=apache2 state=present update_cache=true | ||
+ | # apt: pkg=nginx state=absent update_cache=true | ||
- name: Create index.html file | - name: Create index.html file | ||
template: src=index.html.j2 dest=/var/www/html/index.html | template: src=index.html.j2 dest=/var/www/html/index.html | ||
</code><code> | </code><code> | ||
- | node1# ansible-playbook inst_apache.yml | + | node1# ansible-playbook inst_http.yml |
+ | |||
+ | server# ansible-playbook inst_http.yml -i gate, | ||
</code><code> | </code><code> | ||
# cat iax.conf.j2 | # cat iax.conf.j2 | ||
Line 452: | Line 456: | ||
# hosts: kubes | # hosts: kubes | ||
# hosts: "{{ variable_host | default('addnodes') }}" | # hosts: "{{ variable_host | default('addnodes') }}" | ||
- | "{{ variable_host | default('addnodes') }}" | ||
roles: | roles: | ||
- node | - node | ||
Line 523: | Line 526: | ||
address {{ ansible_eth0.ipv4.address }} | address {{ ansible_eth0.ipv4.address }} | ||
netmask 255.255.255.0 | netmask 255.255.255.0 | ||
- | {% if variable_host == 'all' %} | + | {% if variable_host is defined %} |
gateway 192.168.{{ X }}.1 | gateway 192.168.{{ X }}.1 | ||
{% else %} | {% else %} | ||
Line 541: | Line 544: | ||
==== Роль OpenVPN сервера ==== | ==== Роль OpenVPN сервера ==== | ||
+ | |||
+ | * [[Пакет OpenVPN]] | ||
+ | |||
<code> | <code> | ||
server:~# mkdir openvpn1 && cd openvpn1 | server:~# mkdir openvpn1 && cd openvpn1 | ||
Line 631: | Line 637: | ||
vars: | vars: | ||
X: "{{ ansible_eth1.ipv4.address.split('.')[2] }}" | X: "{{ ansible_eth1.ipv4.address.split('.')[2] }}" | ||
- | ansible_python_interpreter: "/usr/bin/python3" | ||
ansible_ssh_user: vagrant | ansible_ssh_user: vagrant | ||
ansible_ssh_pass: strongpassword | ansible_ssh_pass: strongpassword | ||
Line 658: | Line 663: | ||
</code><code> | </code><code> | ||
server:~# wget https://val.bmstu.ru/unix/conf.git/conf/ansible/roles/openvpn1.tgz && tar -xvzf openvpn1.tgz && cd openvpn1 | server:~# wget https://val.bmstu.ru/unix/conf.git/conf/ansible/roles/openvpn1.tgz && tar -xvzf openvpn1.tgz && cd openvpn1 | ||
+ | |||
+ | server:~/openvpn1# ansible -m ping -i inventory.yaml all | ||
server:~/openvpn1# ansible-playbook openvpn1.yaml -i inventory.yaml -e "variable_host=test_nodes" | server:~/openvpn1# ansible-playbook openvpn1.yaml -i inventory.yaml -e "variable_host=test_nodes" |