Gather facts for one group to run playbook on another

I’d like to gather facts from one group of servers for running a playbook on another group. Crucially, I don’t want to run tasks on the first group, just the fact-gathering.

For example, I want to run a playbook for a group of app servers, which needs the facts of the database servers group for database IP addresses.

-Paul
@paulsmith
pauladamsmith.com

Hi Paul,

The trick is to either (A) have a playbook that talks to both groups like so:

  • hosts: onegroup
    tasks:

  • hosts: othergroup
    tasks:

Or (B), if using 1.8, enable “fact caching” and gather facts on onegroup and then have your other play use that cache.

http://docs.ansible.com/playbooks_variables.html#fact-caching

Let me know if this helps or you have further questions!

Thanks!