Ansible cisco_ios. Change Tunnel Interface Only Settings

35 views
Skip to first unread message

Вадим Воронов

unread,
Jul 1, 2021, 9:09:51 AM7/1/21
to Ansible Project
I collect information about interfaces and after that I need to add the command "no cdp enable" in the tunnels. With the first part, it somehow worked out, but now how to select only the tunnels and add information?


tasks:
   - name: Gather facts (ios)
     cisco.ios.ios_facts:
         gather_subset: min
         gather_network_resources:
             - l3_interfaces

   - name: Store facts to host_vars
     copy
: content: "{{ ansible_network_resources | dict2items }}"
     dest: "{{ playbook_dir }}/backup/{{ inventory_hostname }}"

   - name: configure interface settings
     cisco.ios.ios_config:
        lines:
             - no cdp enable
     parents: interface {{ ansible_network_resources.l3_interfaces['name'] }} # what is the format of this string?
.
.
.
[{"key": "l3_interfaces", "value": [{"name": "Tunnel1", "ipv4": [{"address": "10.111.22.23 255.255.255.224"}]}, {"name": "Tunnel2", "ipv4": [{"address": "10.111.24.23 255.255.255.224"}]}, {"name": "FastEthernet0/0"}, {"name": "FastEthernet0/0.1", "ipv4": [{"address": "10.205.23.2 255.255.255.0"}]}, {"name": "FastEthernet0/0.2", "ipv4": [{"address": "10.205.254.197 255.255.255.252"}]}, {"name": "FastEthernet0/0.3", "ipv4": [{"address": "10.111.210.82 255.255.255.252"}]}, {"name": "FastEthernet0/1"}, {"name": "FastEthernet0/1.3", "ipv4": [{"address": "10.111.21.82 255.255.255.252"}]}, {"name": "Serial0/2/0"}, {"name": "Serial0/2/1"}]}]

Reply all
Reply to author
Forward
0 new messages