ansible and /etc/hosts
/etc/hosts is "local DNS"
when we need real hostname in /etc/ansible/hosts we use /etc/hosts
like this:
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.2.6 tom_jerry
10.0.2.7 sport_billy
10.0.2.8 arsen_lupin
[root@localhost ~]#
we can work via hostnames in ansible:
[root@localhost ~]# tail -n 5 /etc/ansible/hosts
tom_jerry
sport_billy
arsen_lupin
use this hostnames in ansible (ping-pong):
ansible all -m ping
arsen_lupin | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
sport_billy | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
tom_jerry | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
Žiadne komentáre:
Zverejnenie komentára