Ansible concepts
From wikinotes
Ansible is a program used to automate setup/updates to several remote machines at once. Plays, variables, tasks, files, etc are divided into various YAML files, and organized into roles. The basic file structure looks like the following:
site.yml
role_A.yml
roles/
common/
...
role_A/
files/
templates/
tasks/
handlers/
vars/
defaults/
meta/
The syntax of these yaml files, whether task, playbooks etc, looks roughly like the following:
---
- name: Test Connectivity
hosts: bsd:linux
tasks:
- name: echo "string" test
raw: echo "test"
Each controlled machine is added to a configurable nested ini-style hosts file. Each of these machines is expected to have either an ssh-server (with keys already exchanged), or winrm.
[bsd]
192.168.1.2:22
192.168.1.3:22
[bsd:vars]
ansible_python_interpreter=/usr/local/bin/python2
[arch]
192.168.1.4:22
192.168.1.5:22
Playbooks are run from the command-line. Each task in a play is run on all machines. If a single task fails, the remainder of the tasks in that play are not run on that host.
ansible all -m ping
ansible all -m win_ping
ansible -m setup <hostname> # get all variables/facts
ansible-playbook myy_play.yml # run playbook