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.

68 lines
2.5 KiB

  1. ---
  2. - name: Configure | Check if member is in etcd cluster
  3. shell: "{{ bin_dir }}/etcdctl --no-sync --endpoints={{ etcd_access_addresses }} member list | grep -q {{ etcd_access_address }}"
  4. register: etcd_member_in_cluster
  5. ignore_errors: true
  6. changed_when: false
  7. check_mode: no
  8. when: is_etcd_master
  9. tags:
  10. - facts
  11. environment:
  12. ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem"
  13. ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem"
  14. - name: Configure | Check if member is in etcd-events cluster
  15. shell: "{{ bin_dir }}/etcdctl --no-sync --endpoints={{ etcd_events_access_addresses }} member list | grep -q {{ etcd_access_address }}"
  16. register: etcd_events_member_in_cluster
  17. ignore_errors: true
  18. changed_when: false
  19. check_mode: no
  20. when: is_etcd_master and etcd_events_cluster_setup
  21. tags:
  22. - facts
  23. environment:
  24. ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem"
  25. ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem"
  26. - name: Configure | Copy etcd.service systemd file
  27. template:
  28. src: "etcd-{{ etcd_deployment_type }}.service.j2"
  29. dest: /etc/systemd/system/etcd.service
  30. backup: yes
  31. when: is_etcd_master
  32. notify: restart etcd
  33. - name: Configure | Copy etcd-events.service systemd file
  34. template:
  35. src: "etcd-events-host.service.j2"
  36. dest: /etc/systemd/system/etcd-events.service
  37. backup: yes
  38. when: is_etcd_master and etcd_deployment_type == "host" and etcd_events_cluster_setup
  39. notify: restart etcd-events
  40. - name: Configure | Copy etcd-events.service systemd file
  41. template:
  42. src: "etcd-events-docker.service.j2"
  43. dest: /etc/systemd/system/etcd-events.service
  44. backup: yes
  45. when: is_etcd_master and etcd_deployment_type == "docker" and etcd_events_cluster_setup
  46. notify: restart etcd-events
  47. - name: Configure | Join member(s) to etcd cluster one at a time
  48. include_tasks: join_etcd_member.yml
  49. vars:
  50. target_node: "{{ item }}"
  51. loop_control:
  52. pause: 10
  53. with_items: "{{ groups['etcd'] }}"
  54. when: inventory_hostname == item and etcd_member_in_cluster.rc != 0 and etcd_cluster_is_healthy.rc == 0
  55. - name: Configure | Join member(s) to etcd-events cluster one at a time
  56. include_tasks: join_etcd-evetns_member.yml
  57. vars:
  58. target_node: "{{ item }}"
  59. loop_control:
  60. pause: 10
  61. with_items: "{{ groups['etcd'] }}"
  62. when: inventory_hostname == item and etcd_events_cluster_setup and etcd_events_member_in_cluster.rc != 0 and etcd_events_cluster_is_healthy.rc == 0