kolla-ansible/ansible/roles/etcd/tasks/bootstrap.yml
Jan Gutter ed3b27cc92 etcd: Add support for more scenarios
This commit addresses a few shortcomings in the etcd service:
  * Adding or removing etcd nodes required manual intervention.

  * The etcd service would have brief outages during upgrades or
    reconfigures because restarts weren't always serialised.

This makes the etcd service follow a similar pattern to mariadb:
  * There is now a distiction between bootstrapping the cluster
    and adding / removing another member.

  * This more closely follows etcd's upstream bootstrapping
    guidelines.

  * The etcd role now serialises restarts internally so the
    kolla_serial pattern is no longer appropriate (or necessary).

This does not remove the need for manual intervention in all
failure modes: the documentation has been updated to address the
most common issues.

Note that there's repetition in the container specifications: this
is somewhat deliberate. In a future cleanup, it's intended to reduce
the duplication.

Change-Id: I39829ba0c5894f8e549f9b83b416e6db4fafd96f
2023-11-28 18:43:56 +01:00

26 lines
1.3 KiB
YAML

---
- import_tasks: lookup_cluster.yml
# NOTE(jan.gutter): The following two tasks set facts that aren't really used.
# They serve the purpose to trigger the handlers for bootstrapping:
# If no etcd data volumes exist, bootstrap a new initial cluster.
# If some volumes exist, add the new nodes to an existing cluster.
- name: Determine whether a new cluster needs bootstrapping
set_fact:
etcd_bootstrap_cluster: "{% for host in groups['etcd'] %}{{ hostvars[host].ansible_facts.hostname }}={{ etcd_protocol }}://{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ etcd_peer_port }}{% if not loop.last %},{% endif %}{% endfor %}"
when: not (etcd_cluster_exists | bool)
changed_when: not (etcd_cluster_exists | bool)
notify: Bootstrap etcd cluster
- name: Determine when new services need bootstrapping
set_fact:
etcd_bootstrap_services: "{% for host in groups['etcd_had_volume_False'] %}{{ hostvars[host].ansible_facts.hostname }}={{ etcd_protocol }}://{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ etcd_peer_port }}{% if not loop.last %},{% endif %}{% endfor %}"
when:
- etcd_cluster_exists | bool
- groups.etcd_had_volume_False is defined
changed_when:
- etcd_cluster_exists | bool
- groups.etcd_had_volume_False is defined
notify: Bootstrap etcd services