main.yml 3.2 KB

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