On 09. juni 2017 08:43, Rod Oliver wrote:
Thanks again for your reply. I think I have a faulty understanding with the
way that loops and conditionals apply in Ansible.
cdp_nei.response is a list of dictionaries (containing values for interface
name, neighbor name and neighbor interface) and I'm using that as an input
for a loop to build the configuration of the description of the interface
of switch ports (a combination of neighbor name and neighbor interface).
This works without the conditional.
I want to add a conditional that only runs the loop element when neighbor
name is not present in int_stat.response (also a list of dictionaries)
which contains the configured state of the interfaces. Basically the idea
is to create the configuration template to reconfigure the interface
description where it is wrong but not otherwise.
If I understand you correctly you are looking for a loop in a loop.
Do do that in Ansible check out loop control
https://docs.ansible.com/ansible/playbooks_loops.html#loop-control
--
Kai Stian Olstad
--
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/aa2bf52f-d5d6-5a17-0d1c-f23cbaed13c7%40olstad.com.
For more options, visit https://groups.google.com/d/optout.