Hello, I am looking for way to pull interfaces from an cisco switch and 
make them a variable based on they way they are currently configured so I 
can make configuration changes. For example if it is a trunk interface make 
those the variable or list so I can add another allowed vlan. Or if it is 
an access port and this access vlan select those ports so I can make 
changes.

 

I can pull a list of interfaces from a switch using

 

- name: show interfaces

  hosts: all

  connection: network_cli

  gather_facts: no

  vars:

     ansible_network_os: ios

 

  tasks:

 

    - name: test

      ios_facts:

        gather_subset:

        - 'min'

        gather_network_resources:

        - l2_interfaces

 

 

And get this result

 

{

    "ansible_facts": {

        "ansible_network_resources": {

            "l2_interfaces": [

                {

                    "name": "GigabitEthernet0/0"

                },

                {

                    "name": "GigabitEthernet1/0/1",

                    "access": {

                        "vlan": 3456

                    }

                },

                {

                    "name": "GigabitEthernet1/0/2",

                    "access": {

                        "vlan": 3456

                    }

                },

                {

                    "name": "GigabitEthernet1/0/3",

                    "access": {

                        "vlan": 3456

                    }

                },

                {

                    "name": "GigabitEthernet1/0/4",

                    "access": {

                        "vlan": 3456

 

    {

                    "name": "GigabitEthernet1/0/20",

                    "trunk": {

                        "allowed_vlans": [

                            "32",

                            "1978",

                            "1980",

                            "3456"

                        ]

                    }

                },

 

But I am having issues find a way to select and use the interfaces that are 
either a trunk or access and what access vlan to select.

 

Any help with this would be greatly appreciated.

 

Thank you

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4b49600b-7bfe-4cf2-9349-aadce595eb14n%40googlegroups.com.

Reply via email to