Register Variables in Loop in an Ansible Playbook


I have two ansible tasks as follows

which is used to get a list of interfaces in a machine (linux) and get the bus address for each. I have one more task as follows in tha same playbook

which I expect to iterate over value from var2 and then print the bus numbers.

var2.results is as follows

My objective is to get the value of stdout in each item above for example (“stdout”: “09:00.0”) . I tried giving something like

But this is not giving the bus values in stdout correctly. Appreciate help in listing the variable of variable value in task as given below when the second variable is and indexed list. I am trying to avoid direct index numbering such as item[0] because the number of interfaces are dynamic and direct indexing may result in unexpected outcomes.



Is this what you’re looking for:

Leave a Reply