Ansible job definitions for Zuul
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

peer.yaml 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ---
  2. # This dynamically configures a unique offset for this peer
  3. - name: Set offset
  4. set_fact:
  5. offset: "{{ bridge_address_offset | int + 1 + groups['peers'].index(inventory_hostname) }}"
  6. - name: Add additional vni offset
  7. set_fact:
  8. vni: "{{ offset | int + bridge_vni_offset | int }}"
  9. # To make things more readable in the following tasks
  10. - name: Set ip address when the node private IP is not set
  11. set_fact:
  12. nodepool_ip: |
  13. {{ nodepool.private_ipv4 | default(nodepool.public_ipv4) }}
  14. - name: Select the switch from group
  15. set_fact:
  16. switch: "{{ groups['switch'][0] }}"
  17. - name: Alias the primary node private IP
  18. set_fact:
  19. switch_ip: |
  20. {{ hostvars[switch].nodepool.private_ipv4 |
  21. default(hostvars[switch].nodepool.public_ipv4) }}
  22. - name: Add port to bridge on switch node
  23. become: yes
  24. command: >-
  25. ovs-vsctl --may-exist add-port {{ bridge_name }}
  26. {{ bridge_name }}_{{ nodepool_ip }}
  27. -- set interface {{ bridge_name }}_{{ nodepool_ip}}
  28. type=vxlan options:remote_ip={{ nodepool_ip }} options:key={{ vni }}
  29. options:local_ip={{ switch_ip }}
  30. delegate_to: "{{ switch }}"
  31. - name: Create bridge on peer node
  32. become: yes
  33. openvswitch_bridge:
  34. bridge: "{{ bridge_name }}"
  35. - name: Set MTU on peer node bridge
  36. become: yes
  37. command: ip link set mtu {{ bridge_mtu }} dev {{ bridge_name }}
  38. - name: Add port to bridge on peer node
  39. become: yes
  40. command: >-
  41. ovs-vsctl --may-exist add-port {{ bridge_name }}
  42. {{ bridge_name }}_{{ switch_ip }}
  43. -- set interface {{ bridge_name }}_{{ switch_ip }}
  44. type=vxlan options:remote_ip={{ switch_ip }} options:key={{ vni }}
  45. options:local_ip={{ nodepool_ip }}
  46. - when: bridge_configure_address
  47. block:
  48. - name: Verify if the bridge address is set
  49. shell: ip addr show dev {{ bridge_name }} | grep -q {{ bridge_address_prefix }}.{{ offset }}/{{ bridge_address_subnet }}
  50. environment:
  51. PATH: '{{ ansible_env.PATH }}:/bin:/sbin:/usr/sbin'
  52. register: ip_addr_var
  53. failed_when: False
  54. changed_when: False
  55. - name: Set the bridge address
  56. become: yes
  57. command: ip addr add {{ bridge_address_prefix }}.{{ offset }}/{{ bridge_address_subnet }} dev {{ bridge_name }}
  58. environment:
  59. PATH: '{{ ansible_env.PATH }}:/bin:/sbin:/usr/sbin'
  60. when: ip_addr_var.rc == 1
  61. - name: Bring subnode bridge interface up
  62. become: yes
  63. command: ip link set dev {{ bridge_name }} up