2018-03-01 08:39:14 +00:00
|
|
|
---
|
|
|
|
- name: Join Member | Add member to cluster
|
|
|
|
shell: "{{ bin_dir }}/etcdctl --endpoints={{ etcd_events_access_addresses }} member add {{ etcd_member_name }} {{ etcd_events_peer_url }}"
|
|
|
|
register: member_add_result
|
|
|
|
until: member_add_result.rc == 0
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
|
|
|
when: target_node == inventory_hostname
|
|
|
|
environment:
|
2018-03-31 18:06:09 +00:00
|
|
|
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem"
|
|
|
|
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem"
|
2018-03-01 08:39:14 +00:00
|
|
|
|
|
|
|
- include_tasks: refresh_config.yml
|
|
|
|
vars:
|
|
|
|
etcd_events_peer_addresses: >-
|
|
|
|
{% for host in groups['etcd'] -%}
|
|
|
|
{%- if hostvars[host]['etcd_events_member_in_cluster'].rc == 0 -%}
|
|
|
|
{{ "etcd"+loop.index|string }}=https://{{ hostvars[host].access_ip | default(hostvars[host].ip | default(hostvars[host].ansible_default_ipv4['address'])) }}:2382,
|
|
|
|
{%- endif -%}
|
|
|
|
{%- if loop.last -%}
|
|
|
|
{{ etcd_member_name }}={{ etcd_events_peer_url }}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- endfor -%}
|
|
|
|
when: target_node == inventory_hostname
|
|
|
|
|
|
|
|
- name: Join Member | reload systemd
|
|
|
|
command: systemctl daemon-reload
|
|
|
|
when: target_node == inventory_hostname
|
|
|
|
|
|
|
|
- name: Join Member | Ensure etcd-events is running
|
|
|
|
service:
|
|
|
|
name: etcd-events
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
when: target_node == inventory_hostname
|
|
|
|
|
|
|
|
- name: Join Member | Ensure member is in etcd-events cluster
|
|
|
|
shell: "{{ bin_dir }}/etcdctl --no-sync --endpoints={{ etcd_events_access_addresses }} member list | grep -q {{ etcd_events_access_address }}"
|
|
|
|
register: etcd_events_member_in_cluster
|
|
|
|
changed_when: false
|
|
|
|
check_mode: no
|
|
|
|
tags:
|
|
|
|
- facts
|
|
|
|
when: target_node == inventory_hostname
|
|
|
|
environment:
|
2018-03-31 18:06:09 +00:00
|
|
|
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}.pem"
|
|
|
|
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ inventory_hostname }}-key.pem"
|