ansibleを触っていこう

[vagrant@host ~]$ ansible –version
ansible 2.2.0.0
config file = /home/vagrant/ansible.cfg
configured module search path = Default w/o overrides

ansibleってレッドハットが所有してるんだ。どうりで。
https://www.ansible.com/

[vagrant@host ~]$ ssh web
Last login: Wed Nov 23 22:41:13 2016 from 192.168.43.51
[vagrant@web ~]$ exit
logout
Connection to 192.168.43.52 closed.
[vagrant@host ~]$ ssh db
Last login: Wed Nov 23 22:41:12 2016 from 192.168.43.51
[vagrant@db ~]$ exit
logout
Connection to 192.168.43.53 closed.

なんじゃこりゃー

inventry file

[web]
192.168.43.52

[db]
192.168.43.53

[vagrant@host ~]$ ansible all -i hosts -m ping
192.168.43.53 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}
192.168.43.52 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}

ansible.cfg

[defaults]
hostfile = ./hosts

[vagrant@host ~]$ ansible all -m ping
192.168.43.53 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}
192.168.43.52 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}