On Thursday, August 23, 2018 at 1:23:23 PM UTC-4, Jameson Pugh wrote:
>
> I apologize, guys. There were some typeos in my example. This isn't the
> actual code I'm using because I tried to simplify the example to only
> include the problem I'm having. This is a copy of the playbook that
> includes on this scenario. Obviously, production playbook I'm putting this
> in will have the variable for the interfaces pulled from the device:
>
> ---
> - hosts: "{{ target }}"
> connection: network_cli
> gather_facts: no
> tasks:
>
> - set_fact:
> interfaces:
> - TenGigabitEthernet 0/32
> - TenGigabitEthernet 0/33
>
> - debug: var={{ item }}
> loop: "{{ interfaces }}"
> when: item[21:]|int <= 32
>
> My goal is to have this only output the first string in the list of
> interfaces as it is equal to or less than 32. In production, this will be a
> much larger list, and I will have other filters, so that it only includes
> my 10 gig interfaces, but the rest of it is already working for me. Thanks.
>
There's nothing wrong with your condition, you're just using debug
incorrectly. 'var' expects a var name, so you're double-interpolating and
telling it to look up the value of the variable named 'TenGigabitEthernet
0/32', which fails.
--
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/4c14a51b-dfa4-4c25-afb3-45abdb8175d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.