I’m trying to write a conditional to only act on members of a list of strings when two characters in the string are less than a given number. Does anyone know if this is possible? What I’m trying now looks like:
set_fact:
interfaces:
When I attempt this, I get, “template error while templating string: expected token ‘end of print statement’, got ‘integer’. String: {{TenGigabitEthernet 0/32}}”
Any thoughts how how to achieve this are appreciated.
I'm trying to write a conditional to only act on members of a list of
strings when two characters in the string are less than a given number.
Does anyone know if this is possible? What I'm trying now looks like:
set_fact:
interfaces:
- TenGigabitEthernet 0/32
- TenGigabitEthernet 0/33
The same does this debug.
And loop and when is indented to far in.
var= takes a variable name and not the content of one, a valid expression would be var=interfaces
Why are you using {{ facts }} it doesn't exist anywhere else in your code.
Slicing in Python is [from and including:up to but not including] so your [21:22] need to be [21:23] or just [21:] which is to the end of the line.
When I attempt this, I get, "template error while templating string:
expected token 'end of print statement', got 'integer'. String:
{{TenGigabitEthernet 0/32}}"
Because of all errors you get this message.
So this should work
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:
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.