I am working on a way to register interfaces to use as a variable based on 
the way the port is configured.  For example I want all ports that are 
configured for a trunk or access vlan 10.  I have not found a way to use 
the jinja2 script I have.  The ansible script will go through and make a 
list of all the interfaces and show the configurations but that is where I 
am stuck.  Any help would be appreciated.

---
- name: show interfaces
  hosts: all
  connection: network_cli
  gather_facts: no
  vars:
     ansible_network_os: ios
     my_list: []

  tasks: 
  - name: show interfaces 
    ios_facts: 
      gather_subset: "interfaces"

  - name: get interface
    set_fact: 
      my_list: '{{my_list + [item]}}'
    with_items: "{{ ansible_net_interfaces }}"

  - debug:
      var: my_list

  - name: loop through 
    with_items: " {{ my_list }}"
    ios_command:
      commands: show run interface {{ item }}





{% for interface in __interface %}
  {% if interface.mode == 'trunk' %}
    int {{ interface.portName }}
    switchport trunk allowed vlan add {{ vlan_id }}
  {% endif%}
{% endfor %}

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/545b0600-66a8-45a2-8f02-45f46202be23n%40googlegroups.com.

Reply via email to