main.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ---
  2. - name: Configure switchport interface
  3. nxos_interfaces:
  4. config:
  5. - name: "{{ item.name }}"
  6. enabled: True
  7. mode: layer2
  8. with_items: "{{ n9k_switchports }}"
  9. tags: switchport
  10. - name: Configure switchport description
  11. nxos_interfaces:
  12. config:
  13. - name: "{{ item.name }}"
  14. description: "{{ item.descr }}"
  15. with_items: "{{ n9k_switchports }}"
  16. when: item.descr is defined
  17. tags: switchport
  18. - name: Configure switchport MTU
  19. nxos_interfaces:
  20. config:
  21. - name: "{{ item.name }}"
  22. mtu: "{{ item.mtu }}"
  23. with_items: "{{ n9k_switchports }}"
  24. when: item.mtu is defined
  25. tags: switchport
  26. - name: Configure switchport access parameters
  27. nxos_l2_interfaces:
  28. config:
  29. - name: "{{ item.name }}"
  30. access:
  31. vlan: "{{ item.access_vlan }}"
  32. with_items: "{{ n9k_switchports }}"
  33. when: item.mode == "access"
  34. tags: switchport
  35. - name: Configure switchport trunk parameters
  36. nxos_l2_interfaces:
  37. config:
  38. - name: "{{ item.name }}"
  39. trunk:
  40. allowed_vlans: "{{ item.trunk_allowed_vlans }}"
  41. with_items: "{{ n9k_switchports }}"
  42. when: item.mode == "trunk"
  43. tags: switchport
  44. - name: Configure port-channel interface
  45. nxos_interfaces:
  46. config:
  47. - name: Port-channel{{ item.port_channel }}
  48. enabled: True
  49. mode: layer2
  50. with_items: "{{ n9k_switchports }}"
  51. when: item.port_channel is defined
  52. tags: switchport
  53. - name: Configure port-channel description
  54. nxos_interfaces:
  55. config:
  56. - name: Port-channel{{ item.port_channel }}
  57. description: "{{ item.pc_descr }}"
  58. with_items: "{{ n9k_switchports }}"
  59. when: item.port_channel is defined and item.pc_descr is defined
  60. tags: switchport
  61. - name: Configure port-channel description
  62. nxos_interfaces:
  63. config:
  64. - name: Port-channel{{ item.port_channel }}
  65. description: "{{ item.descr }}"
  66. with_items: "{{ n9k_switchports }}"
  67. when: item.port_channel is defined and item.descr is defined
  68. tags: switchport
  69. - name: Configure port-channel MTU
  70. nxos_interfaces:
  71. config:
  72. - name: Port-channel{{ item.port_channel }}
  73. mtu: "{{ item.mtu }}"
  74. with_items: "{{ n9k_switchports }}"
  75. when: item.port_channel is defined and item.mtu is defined
  76. tags: switchport
  77. - name: Configure port-channel access parameters
  78. nxos_l2_interfaces:
  79. config:
  80. - name: Port-channel{{ item.port_channel }}
  81. access:
  82. vlan: "{{ item.access_vlan }}"
  83. with_items: "{{ n9k_switchports }}"
  84. when: item.port_channel is defined and item.mode == "access"
  85. tags: switchport
  86. - name: Configure port-channel trunk parameters
  87. nxos_l2_interfaces:
  88. config:
  89. - name: Port-channel{{ item.port_channel }}
  90. trunk:
  91. allowed_vlans: "{{ item.trunk_allowed_vlans }}"
  92. with_items: "{{ n9k_switchports }}"
  93. when: item.port_channel is defined and item.mode == "trunk"
  94. tags: switchport
  95. - name: Configure port-channel link aggregation
  96. nxos_config:
  97. lines:
  98. - channel-group {{ item.port_channel }} mode active
  99. parents: interface {{ item.name }}
  100. with_items: "{{ n9k_switchports }}"
  101. when: item.port_channel is defined
  102. tags: switchport
  103. - name: Set vPC on port-channel interface
  104. nxos_vpc_interface:
  105. portchannel: "{{ item.port_channel }}"
  106. vpc: "{{ item.port_channel }}"
  107. with_items: "{{ n9k_switchports }}"
  108. when: item.port_channel is defined and item.vpc is defined
  109. tags: switchport