Created
June 16, 2014 17:57
-
-
Save phips/2a51a5d32fdff4dcb719 to your computer and use it in GitHub Desktop.
hostvars test fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# {{ ansible_managed }} | |
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 | |
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 | |
{% for host in groups.all %} | |
{{ hostvars[host]['ansible_eth0']['ipv4']['address'] }} {{ host }} | |
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible-playbook site.yml --limit master | |
PLAY [all] ******************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [master] | |
TASK: [hosts | Ensure hostname set] ******************************************* | |
ok: [master] | |
TASK: [hosts | DEBUG] ********************************************************* | |
ok: [master] => { | |
"msg": "10.16.216.135" | |
} | |
TASK: [hosts | Ensure /etc/hosts populated] *********************************** | |
fatal: [master] => {'msg': "One or more undefined variables: 'dict object' has no attribute 'ansible_eth0'", 'failed': True} | |
fatal: [master] => {'msg': "One or more undefined variables: 'dict object' has no attribute 'ansible_eth0'", 'failed': True} | |
FATAL: all hosts have already failed -- aborting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible-playbook site.yml | |
PLAY [all] ******************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [master] | |
ok: [ansible-target] | |
TASK: [hosts | Ensure hostname set] ******************************************* | |
ok: [ansible-target] | |
ok: [master] | |
TASK: [hosts | DEBUG] ********************************************************* | |
ok: [master] => { | |
"msg": "10.16.216.135" | |
} | |
ok: [ansible-target] => { | |
"msg": "10.16.216.179" | |
} | |
TASK: [hosts | Ensure /etc/hosts populated] *********************************** | |
ok: [master] | |
ok: [ansible-target] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat site.yml | |
--- | |
- hosts: all | |
sudo: true | |
gather_facts: true | |
roles: | |
- hosts | |
- hosts: master | |
sudo: true | |
roles: | |
- ansible |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment