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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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: Alias the primary node private IP
  11. set_fact:
  12. switch_private_ip: "{{ hostvars[groups['switch'][0]]['nodepool']['private_ipv4'] }}"
  13. - name: Add port to bridge on switch node
  14. become: yes
  15. command: >-
  16. ovs-vsctl --may-exist add-port {{ bridge_name }}
  17. {{ bridge_name }}_{{ nodepool['private_ipv4'] }}
  18. -- set interface {{ bridge_name }}_{{ nodepool['private_ipv4'] }}
  19. type=vxlan options:remote_ip={{ nodepool['private_ipv4'] }} options:key={{ vni }}
  20. options:local_ip={{ switch_private_ip }}
  21. delegate_to: "{{ groups['switch'][0] }}"
  22. - name: Create bridge on peer node
  23. become: yes
  24. openvswitch_bridge:
  25. bridge: "{{ bridge_name }}"
  26. - name: Set MTU on peer node bridge
  27. become: yes
  28. command: ip link set mtu {{ bridge_mtu }} dev {{ bridge_name }}
  29. - name: Add port to bridge on peer node
  30. become: yes
  31. command: >-
  32. ovs-vsctl --may-exist add-port {{ bridge_name }}
  33. {{ bridge_name }}_{{ switch_private_ip }}
  34. -- set interface {{ bridge_name }}_{{ switch_private_ip }}
  35. type=vxlan options:remote_ip={{ switch_private_ip }} options:key={{ vni }}
  36. options:local_ip={{ nodepool['private_ipv4'] }}
  37. - when: bridge_configure_address
  38. block:
  39. - name: Verify if the bridge address is set
  40. shell: ip addr show dev {{ bridge_name }} | grep -q {{ bridge_address_prefix }}.{{ offset }}/{{ bridge_address_subnet }}
  41. environment:
  42. PATH: '{{ ansible_env.PATH }}:/bin:/sbin:/usr/sbin'
  43. register: ip_addr_var
  44. failed_when: False
  45. changed_when: False
  46. - name: Set the bridge address
  47. become: yes
  48. command: ip addr add {{ bridge_address_prefix }}.{{ offset }}/{{ bridge_address_subnet }} dev {{ bridge_name }}
  49. environment:
  50. PATH: '{{ ansible_env.PATH }}:/bin:/sbin:/usr/sbin'
  51. when: ip_addr_var.rc == 1
  52. - name: Bring subnode bridge interface up
  53. become: yes
  54. command: ip link set dev {{ bridge_name }} up