This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
сервис_ansible [2025/01/11 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 337: | Line 334: | ||
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=present update_cache=true | + | # apt: pkg=nginx state=absent update_cache=true |
- name: Create index.html file | - name: Create index.html file | ||
Line 459: | 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 530: | 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 548: | Line 544: | ||
==== Роль OpenVPN сервера ==== | ==== Роль OpenVPN сервера ==== | ||
+ | |||
+ | * [[Пакет OpenVPN]] | ||
+ | |||
<code> | <code> | ||
server:~# mkdir openvpn1 && cd openvpn1 | server:~# mkdir openvpn1 && cd openvpn1 | ||
Line 638: | 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 665: | 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" |