So pretty much limit in ansible works, so you shouldn't feel the need to
double check it.
If you must, I would do this, and keep in mind you don't use "{{ }}" in
conditionals in ansible.
- assert:
that:
- item in play_hosts
with_items: required_servers
On Wed, Oct 15, 2014 at 8:49 PM, David Judd <[email protected]> wrote:
> 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
> <https://groups.google.com/d/msgid/ansible-project/16430f19-2e86-4dcb-b2f5-5b016cc2dfe8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CA%2BnsWgzqmUt6-ML0zsDaZ%3DnApqO5w0emn%2B0OFOFPXhcwoom0Tw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.