3 ms·
Ansible doesn't store them, but exchanges them in memory. (The assumption is you'd want them to be current anyway). We are going to add some optional caching (
by mpdehaan2 13y ago
Ansible doesn't store them, but exchanges them in memory. (The assumption is you'd want them to be current anyway). We are going to add some optional caching (likely just requiring sqlite as it's all we need) in a future release.
But yes, it's easy to do that. Assuming you meant a template, you could do:
{% for host in groups["datacenterX"] %}
{% if host in groups["Y"] %}
{{ ssh_host_key_rsa_public }}
{% end if %}
{% endif %}
Ansible is also good at carving up groups based on these things, like if you just wanted to talk to those hosts:
hosts: datacenterX:&Y
note that Hacker News ate my newlines.
etc
- jessaustin 13y agonote that Hacker News ate my newlines. If you want to edit the post to include them, indent by at least four spaces the text for which newlines are important. Maybe like this: {% for host in groups["datacenterX"] %} {% if host in groups["Y"] %} {{ ssh_host_key_rsa_public }} {% end if %} {% endif %} [sic]
- otterley 13y ago> Ansible doesn't store them, but exchanges them in memory (The assumption is you'd want them to be current anyway). What happens if the server crashes? Can a subsequent run before all the data is repopulated cause the derived files to have invalid or missing data?
- mpdehaan2 13y agoIt's saving them in memory now so there are no files to corrupt. When you run again it gathers all the facts from the hosts.