Hi everyone,

This is a tricky question which I have been unable to solve so far despîte 
multiple attempts, maybe it is not feasible with Ansible.
I pull some facts from a networking device, some of them end up in {{ 
facts.ansible_facts.ansible_net_neighbors }}:
"ansible_net_neighbors": {
        "Gi0/0": [
            {
                "host": "IOSv_L2_10.actionmystique.net",
                "port": "Gi0/1"
            }
        ],
        "Gi0/3": [
            {
                "host": "IOSv_Leaf_13.actionmystique.net",
                "port": "Gi0/1.10"
            },
            {
                "host": "IOSv_Leaf_13.actionmystique.net",
                "port": "Gi0/1.20"
            },
            {
                "host": "IOSv_Leaf_13.actionmystique.net",
                "port": "Gi0/1"
            }
        ],
        "Gi0/4": [
            {
                "host": "IOSv_Leaf_14.actionmystique.net",
                "port": "Gi0/1"
            },
            {
                "host": "IOSv_Leaf_14.actionmystique.net",
                "port": "Gi0/1.20"
            },
            {
                "host": "IOSv_Leaf_14.actionmystique.net",
                "port": "Gi0/1.10"
            }
        ],
...
The number & names of ansible_net_neighbors sub-elements "Gin/p" (which 
stand for GigabitEthernet n/p) are dynamic: we have no clue in advance what 
they'll be.
Same characteristic for the number of host/port duo(s) inside each "Gin/p"

So, how can I loop over all those sub-elements? The tricky part for me is 
the fact that there is no name for the field "Gin/p".
I have unsuccessfully tried the following for instance:
- name: Updating the description of all interfaces
  ios_config:
        provider: "{{ connections.ssh }}"
        parents: 
          - "interface {{ item }}"
        lines:
          - "description Connected to {{ item.host }} on its port {{ 
item.port }}"
  with_dict: "{{ facts.ansible_facts.ansible_net_neighbors }}"
  register: result

Any ingenious trick in mind?

-- 
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/bb8cd3ca-632c-4731-9716-df0e45c4e9ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to