How would you approach this problem? Host1 needs to dynamically know the IP address of Host2
Here's the basic structure of my playbook:
- Play1 applies to both hosts
- Play2 applies to Host1
In Play2, I have a task that needs to know the IP address of Host2.
How would you typically handle this? It doesn't seem as though I can register a variable in Play1, as the variable isn't accessible to Host1 in Play2.
Thank you in advance!
Posted Mar 17, 2017, 6:29 PM UTC
As long as you gather facts and know the name of those you want a var from, you can use that method.
Ah that looks like a good approach. What about in the case of a group? I.e. multiple hosts.
Thanks!
I would need more context on what you mean by that to answer
Then perform your logic using group variable instead of a hardcoded host name.