a35b6dc1af
* etcd: etcd-events doesn't depend on etcd_cluster_setup Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> * etcd: remove condition already present on include_tasks Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> * etcd: fix scaling up Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> * etcd: use *access_addresses, do not delegate to etcd[0] We want to wait for the full cluster to be healthy, so use all the cluster addresses Also we should be able to run the playbook when etcd[0] is down (not tested), so do not delegate to etcd[0] Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> * etcd: use failed_when for health check unhealthy cluster is expected on first run, so use failed_when instead of ignore_errors to remove scary red messages Also use run_once Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> * kubernetes/preinstall: ensure ansible_fqdn is up to date after changing /etc/hosts Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> * kubernetes/master: regenerate apiserver cert if needed Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
41 lines
1.6 KiB
YAML
41 lines
1.6 KiB
YAML
---
|
|
- name: Join Member | Add member to etcd cluster
|
|
shell: "{{ bin_dir }}/etcdctl --endpoints={{ etcd_access_addresses }} member add {{ etcd_member_name }} {{ etcd_peer_url }}"
|
|
register: member_add_result
|
|
until: member_add_result.rc == 0
|
|
retries: "{{ etcd_retries }}"
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
|
environment:
|
|
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem"
|
|
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem"
|
|
ETCDCTL_CA_FILE: "{{ etcd_cert_dir }}/ca.pem"
|
|
|
|
- include_tasks: refresh_config.yml
|
|
vars:
|
|
etcd_peer_addresses: >-
|
|
{% for host in groups['etcd'] -%}
|
|
{%- if hostvars[host]['etcd_member_in_cluster'].rc == 0 -%}
|
|
{{ "etcd"+loop.index|string }}=https://{{ hostvars[host].access_ip | default(hostvars[host].ip | default(fallback_ips[host])) }}:2380,
|
|
{%- endif -%}
|
|
{%- if loop.last -%}
|
|
{{ etcd_member_name }}={{ etcd_peer_url }}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
|
|
- name: Join Member | Ensure member is in etcd cluster
|
|
shell: "{{ bin_dir }}/etcdctl --no-sync --endpoints={{ etcd_access_addresses }} member list | grep -q {{ etcd_access_address }}"
|
|
register: etcd_member_in_cluster
|
|
changed_when: false
|
|
check_mode: no
|
|
tags:
|
|
- facts
|
|
environment:
|
|
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem"
|
|
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem"
|
|
ETCDCTL_CA_FILE: "{{ etcd_cert_dir }}/ca.pem"
|
|
|
|
- name: Configure | Ensure etcd is running
|
|
service:
|
|
name: etcd
|
|
state: started
|
|
enabled: yes
|