Created
January 23, 2016 04:22
-
-
Save jesselang/fecfb9647c8a3e92022f to your computer and use it in GitHub Desktop.
Example ansible playbook to access facts from a group of hosts from another host
This file contains hidden or 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
--- | |
# Execute using ansible-playbook -i hosts example.yml | |
- hosts: web | |
gather_facts: yes | |
- hosts: db | |
gather_facts: no # optional; speed optimization | |
tasks: | |
- name: Display addresses of all web hosts | |
- debug: msg={{ hostvars[item].ansible_eth0.ipv4.address }} | |
with_items: groups['web'] |
This file contains hidden or 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
[db] | |
localhost | |
# Put your database hosts here | |
[web] | |
localhost | |
# Put your web hosts here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment