On Thursday, August 23, 2018 at 3:14:27 PM UTC-4, Jameson Pugh wrote:
>
> On Thu, Aug 23, 2018 at 2:26 PM flowerysong <[email protected] 
> <javascript:>> wrote:
>
>> 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.
>>
>
> Gotcha, so debug can't be used to debug the output of a loop. Thanks. 
>

Yes, it can. You can do "msg={{ item }}" or "var=item". You just can't do 
what you did. Because it's wrong.

-- 
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/d1af948c-6bbf-472a-931a-9114ce37f020%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to