2016-01-19 22:23:19 +08:00
|
|
|
---
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Backup etcd
|
|
|
|
import_tasks: backup.yml
|
2017-03-17 03:38:13 +08:00
|
|
|
|
2024-11-05 14:11:29 +08:00
|
|
|
- name: Restart etcd
|
2024-07-26 16:11:39 +08:00
|
|
|
systemd_service:
|
2016-11-19 06:08:19 +08:00
|
|
|
name: etcd
|
|
|
|
state: restarted
|
2024-11-05 14:11:29 +08:00
|
|
|
daemon_reload: true
|
2024-09-06 14:56:19 +08:00
|
|
|
when: ('etcd' in group_names)
|
2024-11-05 14:11:29 +08:00
|
|
|
throttle: "{{ groups['etcd'] | length // 2 }}"
|
|
|
|
# Etcd cluster MUST have an odd number of members
|
|
|
|
# Truncated integer division by 2 will always return (majority - 1) which
|
|
|
|
# means the cluster will keep quorum and stay available
|
2016-11-19 06:08:19 +08:00
|
|
|
|
2024-11-05 14:11:29 +08:00
|
|
|
- name: Restart etcd-events
|
|
|
|
systemd_service:
|
2018-03-01 16:39:14 +08:00
|
|
|
name: etcd-events
|
|
|
|
state: restarted
|
2024-11-05 14:11:29 +08:00
|
|
|
daemon_reload: true
|
|
|
|
# TODO: this seems odd. etcd-events should be a different group possibly ?
|
2024-09-06 14:56:19 +08:00
|
|
|
when: ('etcd' in group_names)
|
2024-11-05 14:11:29 +08:00
|
|
|
throttle: "{{ groups['etcd'] | length // 2 }}"
|
2018-03-01 16:39:14 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Wait for etcd up
|
2017-02-18 05:22:34 +08:00
|
|
|
uri:
|
2024-09-06 14:56:19 +08:00
|
|
|
url: "https://{% if 'etcd' in group_names %}{{ etcd_address }}{% else %}127.0.0.1{% endif %}:2379/health"
|
2024-08-28 13:30:56 +08:00
|
|
|
validate_certs: false
|
2017-11-07 22:06:16 +08:00
|
|
|
client_cert: "{{ etcd_cert_dir }}/member-{{ inventory_hostname }}.pem"
|
|
|
|
client_key: "{{ etcd_cert_dir }}/member-{{ inventory_hostname }}-key.pem"
|
2016-07-19 21:45:37 +08:00
|
|
|
register: result
|
2016-11-09 18:31:12 +08:00
|
|
|
until: result.status is defined and result.status == 200
|
2019-04-24 15:08:05 +08:00
|
|
|
retries: 60
|
|
|
|
delay: 1
|
2023-11-08 19:28:30 +08:00
|
|
|
listen: Restart etcd
|
2016-06-24 20:25:16 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Cleanup etcd backups
|
|
|
|
import_tasks: backup_cleanup.yml
|
2022-08-05 23:09:59 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Wait for etcd-events up
|
2018-03-01 16:39:14 +08:00
|
|
|
uri:
|
2024-09-06 14:56:19 +08:00
|
|
|
url: "https://{% if 'etcd' in group_names %}{{ etcd_address }}{% else %}127.0.0.1{% endif %}:2383/health"
|
2024-08-28 13:30:56 +08:00
|
|
|
validate_certs: false
|
2018-03-01 16:39:14 +08:00
|
|
|
client_cert: "{{ etcd_cert_dir }}/member-{{ inventory_hostname }}.pem"
|
|
|
|
client_key: "{{ etcd_cert_dir }}/member-{{ inventory_hostname }}-key.pem"
|
|
|
|
register: result
|
|
|
|
until: result.status is defined and result.status == 200
|
2019-04-24 15:08:05 +08:00
|
|
|
retries: 60
|
|
|
|
delay: 1
|
2023-11-08 19:28:30 +08:00
|
|
|
listen: Restart etcd-events
|
2018-03-01 16:39:14 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Set etcd_secret_changed
|
2016-11-09 18:44:41 +08:00
|
|
|
set_fact:
|
|
|
|
etcd_secret_changed: true
|