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.

41 lines
1.4 KiB

  1. ---
  2. - name: Join Member | Add member to cluster
  3. shell: "{{ bin_dir }}/etcdctl --endpoints={{ etcd_access_addresses }} member add {{ etcd_member_name }} {{ etcd_peer_url }}"
  4. register: member_add_result
  5. until: member_add_result.rc == 0
  6. retries: 4
  7. delay: "{{ retry_stagger | random + 3 }}"
  8. when: target_node == inventory_hostname
  9. - include: refresh_config.yml
  10. vars:
  11. etcd_peer_addresses: >-
  12. {% for host in groups['etcd'] -%}
  13. {%- if hostvars[host]['etcd_member_in_cluster'].rc == 0 -%}
  14. {{ "etcd"+loop.index|string }}=https://{{ hostvars[host].access_ip | default(hostvars[host].ip | default(hostvars[host].ansible_default_ipv4['address'])) }}:2380,
  15. {%- endif -%}
  16. {%- if loop.last -%}
  17. {{ etcd_member_name }}={{ etcd_peer_url }}
  18. {%- endif -%}
  19. {%- endfor -%}
  20. when: target_node == inventory_hostname
  21. - name: Join Member | reload systemd
  22. command: systemctl daemon-reload
  23. when: target_node == inventory_hostname
  24. - name: Join Member | Ensure etcd is running
  25. service:
  26. name: etcd
  27. state: started
  28. enabled: yes
  29. when: target_node == inventory_hostname
  30. - name: Join Member | Ensure member is in cluster
  31. shell: "{{ bin_dir }}/etcdctl --no-sync --endpoints={{ etcd_access_addresses }} member list | grep -q {{ etcd_access_address }}"
  32. register: etcd_member_in_cluster
  33. changed_when: false
  34. check_mode: no
  35. tags:
  36. - facts
  37. when: target_node == inventory_hostname