diff --git a/ansible/roles/glance/defaults/main.yml b/ansible/roles/glance/defaults/main.yml index fc551a1ad6..ead1a8fe77 100644 --- a/ansible/roles/glance/defaults/main.yml +++ b/ansible/roles/glance/defaults/main.yml @@ -5,6 +5,7 @@ glance_services: glance-api: container_name: glance_api group: glance-api + host_in_groups: "{{ inventory_hostname in glance_api_hosts }}" enabled: true image: "{{ glance_api_image_full }}" environment: "{{ container_proxy }}" diff --git a/ansible/roles/glance/tasks/ceph.yml b/ansible/roles/glance/tasks/ceph.yml index 8acec68ea1..bc29bf2fb1 100644 --- a/ansible/roles/glance/tasks/ceph.yml +++ b/ansible/roles/glance/tasks/ceph.yml @@ -8,7 +8,9 @@ dest: "{{ node_config_directory }}/glance-api/ceph.conf" mode: "0660" become: true - when: inventory_hostname in groups['glance-api'] + when: + - glance_services['glance-api'].host_in_groups | bool + - glance_services['glance-api'].enabled | bool notify: - Restart glance-api container @@ -38,7 +40,9 @@ dest: "{{ node_config_directory }}/glance-api/ceph.client.glance.keyring" mode: "0600" become: true - when: inventory_hostname in groups['glance-api'] + when: + - glance_services['glance-api'].host_in_groups | bool + - glance_services['glance-api'].enabled | bool notify: - Restart glance-api container @@ -49,6 +53,8 @@ recurse: yes owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" - when: inventory_hostname in groups['glance-api'] + when: + - glance_services[item].host_in_groups | bool + - glance_services[item].enabled | bool with_items: - "glance-api" diff --git a/ansible/roles/glance/tasks/config.yml b/ansible/roles/glance/tasks/config.yml index dd34fbadca..5416ce6584 100644 --- a/ansible/roles/glance/tasks/config.yml +++ b/ansible/roles/glance/tasks/config.yml @@ -8,7 +8,7 @@ mode: "0770" become: true when: - - inventory_hostname in groups[item.value.group] + - item.value.host_in_groups | bool - item.value.enabled | bool with_dict: "{{ glance_services }}" @@ -19,7 +19,7 @@ - include_tasks: external_ceph.yml when: - - enable_ceph | bool == False + - not enable_ceph | bool - glance_backend_ceph | bool - name: Check if policies shall be overwritten @@ -47,7 +47,7 @@ become: true when: - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] + - item.value.host_in_groups | bool with_dict: "{{ glance_services }}" notify: - Restart {{ item.key }} container @@ -67,7 +67,7 @@ become: true when: - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] + - item.value.host_in_groups | bool with_dict: "{{ glance_services }}" notify: - Restart {{ item.key }} container @@ -86,7 +86,7 @@ become: true when: - glance_api.enabled | bool - - inventory_hostname in groups[glance_api.group] + - glance_api.host_in_groups | bool - enable_glance_image_cache | bool notify: - Restart glance-api container @@ -105,7 +105,7 @@ become: true when: - glance_api.enabled | bool - - inventory_hostname in groups[glance_api.group] + - glance_api.host_in_groups | bool - glance_backend_swift | bool notify: - Restart glance-api container @@ -118,7 +118,7 @@ become: true when: - glance_policy_file is defined - - inventory_hostname in groups[item.value.group] + - item.value.host_in_groups | bool - item.value.enabled | bool with_dict: "{{ glance_services }}" notify: @@ -136,7 +136,7 @@ dimensions: "{{ item.value.dimensions }}" when: - kolla_action != "config" - - inventory_hostname in groups[item.value.group] + - item.value.host_in_groups | bool - item.value.enabled | bool with_dict: "{{ glance_services }}" notify: diff --git a/ansible/roles/glance/tasks/external_ceph.yml b/ansible/roles/glance/tasks/external_ceph.yml index 33b20731b8..62c977bd49 100644 --- a/ansible/roles/glance/tasks/external_ceph.yml +++ b/ansible/roles/glance/tasks/external_ceph.yml @@ -5,7 +5,9 @@ dest: "{{ node_config_directory }}/glance-api/" mode: "0660" become: true - when: inventory_hostname in groups['glance-api'] + when: + - glance_services['glance-api'].host_in_groups | bool + - glance_services['glance-api'].enabled | bool with_fileglob: - "{{ node_custom_config }}/glance/ceph*" notify: @@ -18,6 +20,8 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" become: true - when: inventory_hostname in groups['glance-api'] + when: + - glance_services[item].host_in_groups | bool + - glance_services[item].enabled | bool with_items: - "glance-api" diff --git a/ansible/roles/glance/tasks/precheck.yml b/ansible/roles/glance/tasks/precheck.yml index 2be891740d..49337a4e77 100644 --- a/ansible/roles/glance/tasks/precheck.yml +++ b/ansible/roles/glance/tasks/precheck.yml @@ -13,5 +13,6 @@ timeout: 1 state: stopped when: - - inventory_hostname in groups[glance_services['glance-api']['group']] + - glance_services['glance-api'].host_in_groups | bool + - glance_services['glance-api'].enabled | bool - container_facts['glance_api'] is not defined diff --git a/ansible/roles/glance/tasks/pull.yml b/ansible/roles/glance/tasks/pull.yml index d12f8d304b..1de70396f6 100644 --- a/ansible/roles/glance/tasks/pull.yml +++ b/ansible/roles/glance/tasks/pull.yml @@ -6,6 +6,6 @@ common_options: "{{ docker_common_options }}" image: "{{ item.value.image }}" when: - - inventory_hostname in groups[item.value.group] + - item.value.host_in_groups | bool - item.value.enabled | bool with_dict: "{{ glance_services }}" diff --git a/ansible/roles/glance/tasks/stop_service.yml b/ansible/roles/glance/tasks/stop_service.yml index fa4d019ca0..a98c460757 100644 --- a/ansible/roles/glance/tasks/stop_service.yml +++ b/ansible/roles/glance/tasks/stop_service.yml @@ -7,3 +7,6 @@ action: "stop_container" common_options: "{{ docker_common_options }}" name: "{{ glance_api.container_name }}" + when: + - glance_api.host_in_groups | bool + - glance_api.enabled | bool