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.6 KiB

  1. ---
  2. - name: Join Member | Add member to etcd 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: "{{ etcd_retries }}"
  7. delay: "{{ retry_stagger | random + 3 }}"
  8. environment:
  9. ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem"
  10. ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem"
  11. ETCDCTL_CA_FILE: "{{ etcd_cert_dir }}/ca.pem"
  12. - include_tasks: refresh_config.yml
  13. vars:
  14. etcd_peer_addresses: >-
  15. {% for host in groups['etcd'] -%}
  16. {%- if hostvars[host]['etcd_member_in_cluster'].rc == 0 -%}
  17. {{ "etcd"+loop.index|string }}=https://{{ hostvars[host].access_ip | default(hostvars[host].ip | default(fallback_ips[host])) }}:2380,
  18. {%- endif -%}
  19. {%- if loop.last -%}
  20. {{ etcd_member_name }}={{ etcd_peer_url }}
  21. {%- endif -%}
  22. {%- endfor -%}
  23. - name: Join Member | Ensure member is in etcd cluster
  24. shell: "{{ bin_dir }}/etcdctl --no-sync --endpoints={{ etcd_access_addresses }} member list | grep -q {{ etcd_access_address }}"
  25. register: etcd_member_in_cluster
  26. changed_when: false
  27. check_mode: no
  28. tags:
  29. - facts
  30. environment:
  31. ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem"
  32. ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem"
  33. ETCDCTL_CA_FILE: "{{ etcd_cert_dir }}/ca.pem"
  34. - name: Configure | Ensure etcd is running
  35. service:
  36. name: etcd
  37. state: started
  38. enabled: yes