I have a playbook which performs a potentially destructive action, which I
expect to run with --limit normally, and I would like to assert that all
hosts which meet a certain condition are included in my --limit to avoid
unexpected behavior. The particular use case is failing over a PostgreSQL
master and updating all replicas correspondingly.
I don't have a problem getting the list to validate against (I use an
ansible_local fact), but I can't figure out how to get a property of each
host present in hostvars as a list. So I want to be able to say something
like:
- name: validate all streaming replicas are in scope
> assert:
> that:
> - "{{ item }} in {{
> hostvars.values()|map(attribute='ansible_default_ipv4')|map('address') }}"
> with_items: ansible_local.academia.pg_streaming_replicas
when: inventory_hostname == old_master
But
"hostvars.values()|map(attribute='ansible_default_ipv4')|map('address')"
doesn't do what I expect, and neither does any variant I've tried. What's
the right way to get the list of IPs for all hosts that Ansible knows about?
-David
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/16430f19-2e86-4dcb-b2f5-5b016cc2dfe8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.