Fix glance with file backend

Since https://review.opendev.org/647699/, we lost the logic to only
deploy glance-api on a single host when using the file backend.

This code was always a bit custom, and would be better supported by
using the 'host_in_groups' pattern we have in a few other places where a
single group name does not describe the placement of containers for a
service.

Change-Id: I21ce4a3b0beee0009ac69fecd0ce24efebaf158d
Closes-Bug: #1836151
This commit is contained in:
Mark Goddard 2019-07-11 09:16:51 +01:00
parent 6d6aa27f50
commit 602f89baa6
7 changed files with 30 additions and 15 deletions

View File

@ -5,6 +5,7 @@ glance_services:
glance-api: glance-api:
container_name: glance_api container_name: glance_api
group: glance-api group: glance-api
host_in_groups: "{{ inventory_hostname in glance_api_hosts }}"
enabled: true enabled: true
image: "{{ glance_api_image_full }}" image: "{{ glance_api_image_full }}"
environment: "{{ container_proxy }}" environment: "{{ container_proxy }}"

View File

@ -8,7 +8,9 @@
dest: "{{ node_config_directory }}/glance-api/ceph.conf" dest: "{{ node_config_directory }}/glance-api/ceph.conf"
mode: "0660" mode: "0660"
become: true 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: notify:
- Restart glance-api container - Restart glance-api container
@ -38,7 +40,9 @@
dest: "{{ node_config_directory }}/glance-api/ceph.client.glance.keyring" dest: "{{ node_config_directory }}/glance-api/ceph.client.glance.keyring"
mode: "0600" mode: "0600"
become: true 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: notify:
- Restart glance-api container - Restart glance-api container
@ -49,6 +53,8 @@
recurse: yes recurse: yes
owner: "{{ config_owner_user }}" owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}" 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: with_items:
- "glance-api" - "glance-api"

View File

@ -8,7 +8,7 @@
mode: "0770" mode: "0770"
become: true become: true
when: when:
- inventory_hostname in groups[item.value.group] - item.value.host_in_groups | bool
- item.value.enabled | bool - item.value.enabled | bool
with_dict: "{{ glance_services }}" with_dict: "{{ glance_services }}"
@ -19,7 +19,7 @@
- include_tasks: external_ceph.yml - include_tasks: external_ceph.yml
when: when:
- enable_ceph | bool == False - not enable_ceph | bool
- glance_backend_ceph | bool - glance_backend_ceph | bool
- name: Check if policies shall be overwritten - name: Check if policies shall be overwritten
@ -47,7 +47,7 @@
become: true become: true
when: when:
- item.value.enabled | bool - item.value.enabled | bool
- inventory_hostname in groups[item.value.group] - item.value.host_in_groups | bool
with_dict: "{{ glance_services }}" with_dict: "{{ glance_services }}"
notify: notify:
- Restart {{ item.key }} container - Restart {{ item.key }} container
@ -67,7 +67,7 @@
become: true become: true
when: when:
- item.value.enabled | bool - item.value.enabled | bool
- inventory_hostname in groups[item.value.group] - item.value.host_in_groups | bool
with_dict: "{{ glance_services }}" with_dict: "{{ glance_services }}"
notify: notify:
- Restart {{ item.key }} container - Restart {{ item.key }} container
@ -86,7 +86,7 @@
become: true become: true
when: when:
- glance_api.enabled | bool - glance_api.enabled | bool
- inventory_hostname in groups[glance_api.group] - glance_api.host_in_groups | bool
- enable_glance_image_cache | bool - enable_glance_image_cache | bool
notify: notify:
- Restart glance-api container - Restart glance-api container
@ -105,7 +105,7 @@
become: true become: true
when: when:
- glance_api.enabled | bool - glance_api.enabled | bool
- inventory_hostname in groups[glance_api.group] - glance_api.host_in_groups | bool
- glance_backend_swift | bool - glance_backend_swift | bool
notify: notify:
- Restart glance-api container - Restart glance-api container
@ -118,7 +118,7 @@
become: true become: true
when: when:
- glance_policy_file is defined - glance_policy_file is defined
- inventory_hostname in groups[item.value.group] - item.value.host_in_groups | bool
- item.value.enabled | bool - item.value.enabled | bool
with_dict: "{{ glance_services }}" with_dict: "{{ glance_services }}"
notify: notify:
@ -136,7 +136,7 @@
dimensions: "{{ item.value.dimensions }}" dimensions: "{{ item.value.dimensions }}"
when: when:
- kolla_action != "config" - kolla_action != "config"
- inventory_hostname in groups[item.value.group] - item.value.host_in_groups | bool
- item.value.enabled | bool - item.value.enabled | bool
with_dict: "{{ glance_services }}" with_dict: "{{ glance_services }}"
notify: notify:

View File

@ -5,7 +5,9 @@
dest: "{{ node_config_directory }}/glance-api/" dest: "{{ node_config_directory }}/glance-api/"
mode: "0660" mode: "0660"
become: true 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: with_fileglob:
- "{{ node_custom_config }}/glance/ceph*" - "{{ node_custom_config }}/glance/ceph*"
notify: notify:
@ -18,6 +20,8 @@
owner: "{{ config_owner_user }}" owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}" group: "{{ config_owner_group }}"
become: true become: true
when: inventory_hostname in groups['glance-api'] when:
- glance_services[item].host_in_groups | bool
- glance_services[item].enabled | bool
with_items: with_items:
- "glance-api" - "glance-api"

View File

@ -13,5 +13,6 @@
timeout: 1 timeout: 1
state: stopped state: stopped
when: 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 - container_facts['glance_api'] is not defined

View File

@ -6,6 +6,6 @@
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
image: "{{ item.value.image }}" image: "{{ item.value.image }}"
when: when:
- inventory_hostname in groups[item.value.group] - item.value.host_in_groups | bool
- item.value.enabled | bool - item.value.enabled | bool
with_dict: "{{ glance_services }}" with_dict: "{{ glance_services }}"

View File

@ -7,3 +7,6 @@
action: "stop_container" action: "stop_container"
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
name: "{{ glance_api.container_name }}" name: "{{ glance_api.container_name }}"
when:
- glance_api.host_in_groups | bool
- glance_api.enabled | bool