# zypper install ansible

создать inventory   # по умолчанию /etc/ansible/hosts
переназначается через $ANSIBLE_HOSTS или ключ -i
##########################################
host2             ansible_ssh_host=host3.example.org
host3.example.org                              ansible_ssh_user=root
host4.example.org ansible_ssh_host=192.168.1.4 ansible_ssh_user=petrov
[group1]
host[5-8].example.org
[group2]
host[09-12].example.org
[group2:children]
min1
max2
##########################################

Проверка модулей ping, shell, copy

# модуль ping - по всем хостам из /etc/ansible/hosts
ansible -m ping all -i /etc/ansible/hosts

# shell - удаленно выполнить команду, -k запросить пароль
ansible -k -i step-02/hosts -m shell -a 'uname -a' host2

# setup - выдать подробности про сетап хостов
ansible -i step-02/hosts -m setup host2:host05:host04.example.com

# copy - скопировать локальные файлы на удаленный хост
ansible -m copy -a 'src=/etc/motd dest=/tmp/' host4.example.org
                AKA   scp /etc/motd host4.example.org:/tmp






Популярность: 23, Last-modified: Mon, 26 Apr 2021 04:16:26 GMT