From ee7a29cf00d1808fbd0d90be2dc5daf927d07abf Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Tue, 4 Sep 2018 18:51:27 +0100 Subject: [PATCH] Remove compute hosts from etcd group Since I701d495675178c3ed8ec1f00b31d09f198b38a6f merged, etcd only runs on the control hosts, not the compute hosts. We therefore no longer require the etcd group to include the compute hosts. Since the group mapping is now static, we can remove the use of host_in_groups from the etcd service, in favour of the simpler method of specifying the group. Change-Id: Id8f888d7321a30a85ff95e742f7e6c8e2b9c696f Related-Bug: #1790415 --- ansible/inventory/all-in-one | 1 - ansible/inventory/multinode | 1 - ansible/roles/etcd/defaults/main.yml | 6 +----- ansible/roles/etcd/handlers/main.yml | 2 +- ansible/roles/etcd/tasks/config.yml | 6 +++--- ansible/roles/etcd/tasks/precheck.yml | 4 ++-- ansible/roles/etcd/tasks/pull.yml | 2 +- tests/templates/inventory.j2 | 1 - 8 files changed, 8 insertions(+), 15 deletions(-) diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index c6907097ab..4596fa13f6 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -54,7 +54,6 @@ monitoring [etcd:children] control -compute [kafka:children] control diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index b796c2986a..80a39b601b 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -73,7 +73,6 @@ monitoring [etcd:children] control -compute [influxdb:children] monitoring diff --git a/ansible/roles/etcd/defaults/main.yml b/ansible/roles/etcd/defaults/main.yml index 5f2f6a1667..14de766574 100644 --- a/ansible/roles/etcd/defaults/main.yml +++ b/ansible/roles/etcd/defaults/main.yml @@ -14,12 +14,11 @@ etcd_services: ETCD_INITIAL_ADVERTISE_PEER_URLS: "{{ internal_protocol }}://{{ api_interface_address }}:{{ etcd_peer_port }}" ETCD_LISTEN_PEER_URLS: "{{ internal_protocol }}://{{ api_interface_address }}:{{ etcd_peer_port }}" ETCD_INITIAL_CLUSTER_TOKEN: "{{ etcd_cluster_token }}" - ETCD_INITIAL_CLUSTER: "{% for host in etcd_hosts %}{{ hostvars[host]['ansible_hostname'] }}={{ internal_protocol }}://{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ etcd_peer_port }}{% if not loop.last %},{% endif %}{% endfor %}" + ETCD_INITIAL_CLUSTER: "{% for host in groups['etcd'] %}{{ hostvars[host]['ansible_hostname'] }}={{ internal_protocol }}://{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ etcd_peer_port }}{% if not loop.last %},{% endif %}{% endfor %}" ETCD_INITIAL_CLUSTER_STATE: "new" ETCD_OUT_FILE: "/var/log/kolla/etcd/etcd.log" KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" image: "{{ etcd_image_full }}" - host_in_groups: "{{ inventory_hostname in etcd_hosts }}" volumes: - "{{ node_config_directory }}/etcd/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" @@ -35,6 +34,3 @@ etcd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_nam etcd_tag: "{{ openstack_release }}" etcd_image_full: "{{ etcd_image }}:{{ etcd_tag }}" etcd_dimensions: "{{ default_container_dimensions }}" - -# List of hosts running etcd. -etcd_hosts: "{{ groups['control'] }}" diff --git a/ansible/roles/etcd/handlers/main.yml b/ansible/roles/etcd/handlers/main.yml index e5e83c02f3..c9fd38d132 100644 --- a/ansible/roles/etcd/handlers/main.yml +++ b/ansible/roles/etcd/handlers/main.yml @@ -17,6 +17,6 @@ when: - kolla_action != "config" - service.enabled | bool - - service.host_in_groups | bool + - inventory_hostname in groups[service.group] - config_json.changed | bool or etcd_container.changed | bool diff --git a/ansible/roles/etcd/tasks/config.yml b/ansible/roles/etcd/tasks/config.yml index 340d91ea10..dd827b2223 100644 --- a/ansible/roles/etcd/tasks/config.yml +++ b/ansible/roles/etcd/tasks/config.yml @@ -9,7 +9,7 @@ become: true when: - item.value.enabled | bool - - item.value.host_in_groups | bool + - inventory_hostname in groups[item.value.group] with_dict: "{{ etcd_services }}" - name: Copying over config.json files for services @@ -21,7 +21,7 @@ register: etcd_config_jsons when: - item.value.enabled | bool - - item.value.host_in_groups | bool + - inventory_hostname in groups[item.value.group] with_dict: "{{ etcd_services }}" notify: - Restart etcd container @@ -40,7 +40,7 @@ when: - kolla_action != "config" - item.value.enabled | bool - - item.value.host_in_groups | bool + - inventory_hostname in groups[item.value.group] with_dict: "{{ etcd_services }}" notify: - Restart etcd container diff --git a/ansible/roles/etcd/tasks/precheck.yml b/ansible/roles/etcd/tasks/precheck.yml index 8ac30f11bc..8b0a0433f3 100644 --- a/ansible/roles/etcd/tasks/precheck.yml +++ b/ansible/roles/etcd/tasks/precheck.yml @@ -14,7 +14,7 @@ state: stopped when: - container_facts['etcd'] is not defined - - inventory_hostname in groups['etcd'] + - inventory_hostname in groups[etcd_services.etcd.group] - name: Checking free port for Etcd Client wait_for: @@ -25,4 +25,4 @@ state: stopped when: - container_facts['etcd'] is not defined - - inventory_hostname in groups['etcd'] + - inventory_hostname in groups[etcd_services.etcd.group] diff --git a/ansible/roles/etcd/tasks/pull.yml b/ansible/roles/etcd/tasks/pull.yml index e5f18270d6..1c703daf01 100644 --- a/ansible/roles/etcd/tasks/pull.yml +++ b/ansible/roles/etcd/tasks/pull.yml @@ -7,5 +7,5 @@ image: "{{ item.value.image }}" when: - item.value.enabled | bool - - item.value.host_in_groups | bool + - inventory_hostname in groups[item.value.group] with_dict: "{{ etcd_services }}" diff --git a/tests/templates/inventory.j2 b/tests/templates/inventory.j2 index 61dcf28ec8..7cce60a6e4 100644 --- a/tests/templates/inventory.j2 +++ b/tests/templates/inventory.j2 @@ -52,7 +52,6 @@ monitoring [etcd:children] control -compute [karbor:children] control