On Tue, 3 Nov 2020 14:00:49 -0800 (PST)
"[email protected]" <[email protected]> wrote:

> My goal is to have to run the command when it finds 1.1.1.1 or 2.2.2.2 in 
> the output.
> ...
> vars:
>  ips: [1.1.1.1,2.2.2.2]

If tacacs.stdout.0 is a list (not very likely) try this

  when: ips|intersect(tacacs.stdout.0)|length > 0

> when: ("'1.1.1.1' in tacacs.stdout[0]") or
>       ("'2.2.2.2' in tacacs.stdout[0]")

If tacacs.stdout.0 is a text (more likely) try this

  when: tacacs.stdout.0 is search(ips.0|regex_escape()) or
        tacacs.stdout.0 is search(ips.1|regex_escape())

> when tacacs.stdout[0] contains ips

There is no *contains* test in Ansible but you can write one
https://github.com/vbotka/ansible-plugins/blob/master/test_plugins/list.py

If tacacs.stdout.0 is a text with IP value only the previous
solution should work. Or, with the custom test, try this

  when: ips contains(tacacs.stdout.0)

-- 
Vladimir Botka

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20201104001349.71fc9fca%40gmail.com.

Attachment: pgpjkdTwjG2tz.pgp
Description: OpenPGP digital signature

Reply via email to