NXOS Ansible Playbook – Interface Configuration Guide

ansibleciscocisco-nx-osNetwork

Last few days i am playing with cisco nexus switch to deploy config using nxos ansible modules to make it automate.

I am running n3000-uk9-kickstart.6.0.2.U6.6.bin software and here is my playbook snippet where i am trying to configure switch ports.

- name: L2 config for all ports 
      nxos_switchport: interface={{ item }} mode=trunk trunk_vlans=10-11
      with_items:
        - Ethernet1/49
        - Ethernet1/50

my whole playbook run clean without issue but i am only seeing following change, it didn't configure allowed vlans

interface Ethernet1/49
  switchport mode trunk

interface Ethernet1/50
  switchport mode trunk

if this module doesn't work then what other option i have? is there any module i can run and execute arbitrary command line by like?

Best Answer

Finally end up using following module, not pretty but doing what it need to do

- name: sample playbook
  hosts: n3k1

  tasks:

    - name: globle configuration
      nxos_config:
        lines:
          - feature udld
          - feature lacp
          - feature vpc
          - feature lldp
          # Configure spanning-tree
          - spanning-tree port type edge bpduguard default
          - spanning-tree loopguard default
          # Create common users for managment
          - username foo password 5 $1$wK1jW3Lt$LFsugmvA2e8X4en1vs/  role network-admin
          - snmp-server community Sec3atehs@#562gS group network-operator
          - cli alias name wr copy running-config startup-config
        match: line

# Configure vPC peer-link
    - name: configure vpc-peer links
      nxos_config:
        lines:
          - config t
          # Configure vPC peer-link bonding
          - interface Ethernet1/49-50
          - description *** vPC Peer-Link ***
          - switch mode trunk
          - switchport trunk allowed vlan 10-15,20-25
          - channel-group 999 mode active
          - speed 10000
          - exit
        match: line