nxos ansible playbook 来配置界面

网络工程 思科 网络 cisco-nx-os 能听懂的
2021-07-18 08:49:19

最近几天我在玩 cisco nexus switch 来使用nxosansible 模块部署配置以使其自动化。

我正在运行n3000-uk9-kickstart.6.0.2.U6.6.bin软件,这是我尝试配置交换机端口的剧本片段。

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

我的整个剧本毫无问题地运行干净,但我只看到以下更改,它没有配置 allowed vlans

interface Ethernet1/49
  switchport mode trunk

interface Ethernet1/50
  switchport mode trunk

如果这个模块不起作用那么我还有什么其他选择?有没有我可以运行和执行任意命令行的模块?

1个回答

最后最终使用以下模块,不漂亮但做它需要做的事情

- 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