Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ansible can trade data between machines using 'hostvars' as a variable, so you don't even need the analog of Puppet storeconfigs to assemble facts. (Sorry, don't now the Chef term).

Stop by the list if you'd like more info, but it's easy to generate nagios configs from templates this way.



Who stores hostvars? Does Ansible provide a way to extract a subset of them based on other hostvars? (e.g. "give me all the ssh host keys of my hosts in the intersection of datacenter X and hostgroup Y")


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


note 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]


> 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?


It'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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: