kolla-ansible/ansible/roles/etcd/tasks/bootstrap_cluster.yml
Jan Gutter ae21f31785 etcd: deduplicate environments for containers
* etcd service containers usually have a set of
  environment parameters required to boot the container.
* The short-lived etcd bootstrap containers pass extra
  ETCD_INITIAL_* environment variables, but still need to
  pass the ones that the service containers use.
* This uses ansible's `combine` filter to cut down on the
  duplication.
* This is intended to be just a straightforward refactor.

Change-Id: I04e95f92a8f365553afd618d58b99de595d48312
2023-11-29 17:43:22 +00:00

42 lines
1.1 KiB
YAML

---
- name: Bootstrapping etcd cluster
vars:
service_name: "etcd"
service: "{{ etcd_services[service_name] }}"
become: true
kolla_container:
action: "start_container"
common_options: "{{ docker_common_options }}"
environment: "{{ etcd_base_environment | combine(etcd_bootstrap_cluster_environment) }}"
image: "{{ service.image }}"
name: "{{ service.container_name }}"
volumes: "{{ service.volumes }}"
dimensions: "{{ service.dimensions }}"
- name: Wait for etcd service port liveness
wait_for:
host: "{{ api_interface_address }}"
port: "{{ etcd_client_port }}"
connect_timeout: 1
timeout: 60
register: check_etcd_port
until: check_etcd_port is success
retries: 10
delay: 6
- name: Wait for etcd endpoints to be healthy
become: true
vars:
service_name: "etcd"
service: "{{ etcd_services[service_name] }}"
command: >-
{{ kolla_container_engine }} exec {{ service.container_name }}
etcdctl endpoint health
changed_when: false
register: result
until:
- result is success
- ((result.stdout | from_json | first)['health'] | default(False) | bool)
retries: 10
delay: 6