Advertisement
Guest User

Untitled

a guest
Oct 5th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. ###
  2. ### Main YAML file
  3. ###
  4. - hosts: leaf_switches <<< note: this group has two elements, nx3 and nx4
  5. connection: local
  6. roles:
  7. - configure_access_ports
  8.  
  9.  
  10.  
  11. ###
  12. ### vars/main.yaml
  13. ###
  14. ---
  15. # host (switch name), interface, description, mode (access/trunk), vlan_id (native vlan for trunk), allowed_vlans (trunks only), speed, duplex, state (admin state up/down)
  16. port_list:
  17. - { host: "nx3", interface: "Ethernet2/5", description: "server1_eth0", mode: access, vlan_id: "199", speed: "auto", duplex: "auto", state: "up" }
  18. - { host: "nx4", interface: "Ethernet2/5", description: "server1_eth1", mode: access, vlan_id: "199", speed: "auto", duplex: "auto", state: "up" }
  19.  
  20.  
  21.  
  22. ###
  23. ### tasks/main.yaml
  24. ###
  25. ---
  26. - name: Configuring physical interface properties
  27. nxos_interface:
  28. host="{{ item.host }}"
  29. username="{{ username }}"
  30. password="{{ password }}"
  31. transport=nxapi
  32. interface="{{ item.interface }}"
  33. description="{{ item.description }}"
  34. mode=layer2
  35. admin_state="down"
  36. with_items: "{{ port_list }}"
  37. [...]
  38.  
  39.  
  40.  
  41. ###
  42. ### Output
  43. ###
  44. TASK [configure_access_ports : Configuring physical interface properties] ******
  45. changed: [localhost] => (item={u'description': u'server1_eth0', u'duplex': u'auto', u'host': u'nx3', u'state': u'up', u'mode': u'access', u'interface': u'Ethernet2/5', u'speed': u'auto', u'vlan_id': u'199'})
  46. changed: [localhost] => (item={u'description': u'server1_eth1', u'duplex': u'auto', u'host': u'nx4', u'state': u'up', u'mode': u'access', u'interface': u'Ethernet2/5', u'speed': u'auto', u'vlan_id': u'199'})
  47. ok: [localhost] => (item={u'description': u'server2_eth0', u'duplex': u'full', u'host': u'nx3', u'state': u'down', u'mode': u'trunk', u'interface': u'Ethernet2/6', u'allowed_vlans': u'180,199', u'speed': u'1000', u'vlan_id': u'1'})
  48. changed: [localhost] => (item={u'description': u'server3_eth0', u'duplex': u'auto', u'host': u'nx4', u'state': u'up', u'mode': u'access', u'interface': u'Ethernet2/7', u'speed': u'auto', u'vlan_id': u'199'})
  49. changed: [localhost] => (item={u'description': u'server3_eth1', u'duplex': u'auto', u'host': u'nx3', u'state': u'up', u'mode': u'access', u'interface': u'Ethernet2/7', u'speed': u'auto', u'vlan_id': u'199'})
  50. ok: [localhost] => (item={u'description': u'server4_eth0', u'duplex': u'full', u'host': u'nx3', u'state': u'down', u'mode': u'trunk', u'interface': u'Ethernet2/8', u'allowed_vlans': u'180,199', u'speed': u'1000', u'vlan_id': u'1'})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement