Быстрая установка

Материал из megapuper
Перейти к: навигация, поиск

Устанавливаем на хосте управления

apt install software-properties-common
apt-add-repository --yes --update ppa:ansible/ansible
apt install ansible


Конфиг ansible.cfg

[defaults]
inventory      = /etc/ansible/hosts
host_key_checking = False
remote_tmp     = ~/.ansible/tmp
roles_path    = /etc/ansible/roles
callback_plugins   = /usr/share/ansible/plugins/callback

Создаём inventory - hosts

[hosts:vars]
ansible_python_interpreter=/usr/bin/python3
ansible_user=ansible
ansible_become=true
ansible_ssh_private_key_file=/home/ansible/.ssh/id_rsa

[hosts]
app01.iwad.ru
app02.iwad.ru
db01.iwad.ru
db02.iwad.ru

[APP]
app01.iwad.ru
app01.iwad.ru

[DB]
db01.iwad.ru
db02.iwad.ru


Заводим пользователя на клиентах

useradd -u 20000 -s /bin/bash -m -d /home/ansible ansible
mkdir /home/ansible/.ssh
touch /home/ansible/.ssh/authorized_keys
chown -R ansible:ansible /home/ansible
echo "SSH PUBLIC KEY" > /home/ansible/.ssh/authorized_keys
touch /etc/sudoers.d/ansible
echo "ansible ALL=(root) NOPASSWD: ALL" > /etc/sudoers.d/ansible