Ansible автоматизирует задачи на десятках хостов без агентов — только SSH. Установка: apt install ansible.
Inventory (hosts):
[web]
web1.example.com
web2.example.com
[db]
db1.example.com ansible_user=postgres
Ad-hoc команды:
ansible web -i hosts -m ping
ansible web -i hosts -m shell -a "uptime"
ansible all -i hosts -m apt -a "name=nginx state=present" -b
Простой playbook deploy.yml:
- hosts: web
become: true
tasks:
- name: install nginx
apt: name=nginx state=present
- name: start nginx
service: name=nginx state=started enabled=yes
Запуск:
ansible-playbook -i hosts deploy.yml --check # dry-run
ansible-playbook -i hosts deploy.yml
#linux #sysadmin #ansible #devops
