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:
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 }}"

View File

@ -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"

View File

@ -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:

View File

@ -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"

View File

@ -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

View File

@ -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 }}"

View File

@ -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