Refactor the glance service group mapping

Add a glance_service_groups variable containers the container name,
service name and group name. In this way, we can remove lots of
duplicated lines.

TrivialFix

Change-Id: I9beb7509ad7221cd495e3211a2e67d986486aac6
This commit is contained in:
Jeffrey Zhang 2016-03-28 12:25:48 +08:00
parent 9523fd0e56
commit 0a6cff4a6d
3 changed files with 12 additions and 23 deletions

View File

@ -1,5 +1,9 @@
---
project_name: "glance"
glance_service_groups:
- { name: glance_api, service: glance-api, group: glance-api }
- { name: glance_registry, service: glance-registry, group: glance-registry }
####################
# Ceph

View File

@ -5,18 +5,14 @@
state: "directory"
recurse: yes
when: inventory_hostname in groups[item.group]
with_items:
- { service: glance-api, group: glance-api }
- { service: glance-registry, group: glance-registry }
with_items: "{{ glance_service_groups }}"
- name: Copying over config.json files for services
template:
src: "{{ item.service }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.service }}/config.json"
when: inventory_hostname in groups[item.group]
with_items:
- { service: glance-api, group: glance-api }
- { service: glance-registry, group: glance-registry }
with_items: "{{ glance_service_groups }}"
- name: Copying over glance-*.conf
merge_configs:
@ -32,7 +28,4 @@
- "/etc/kolla/config/glance/{{ inventory_hostname }}/{{ item.service }}.conf"
dest: "{{ node_config_directory }}/{{ item.service }}/{{ item.service }}.conf"
when: inventory_hostname in groups[item.group]
with_items:
- { service: glance-api, group: glance-api }
- { service: glance-registry, group: glance-registry }
with_items: "{{ glance_service_groups }}"

View File

@ -6,9 +6,7 @@
register: container_state
failed_when: container_state.Running == false
when: inventory_hostname in groups[item.group]
with_items:
- { name: glance_api, group: glance-api }
- { name: glance_registry, group: glance-registry }
with_items: "{{ glance_service_groups }}"
- include: config.yml
@ -18,9 +16,7 @@
failed_when: false
register: check_results
when: inventory_hostname in groups[item.group]
with_items:
- { name: glance_api, group: glance-api }
- { name: glance_registry, group: glance-registry }
with_items: "{{ glance_service_groups }}"
# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS'
# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE',
@ -31,9 +27,7 @@
action: "get_container_env"
register: container_envs
when: inventory_hostname in groups[item.group]
with_items:
- { name: glance_api, group: glance-api }
- { name: glance_registry, group: glance-registry }
with_items: "{{ glance_service_groups }}"
- name: Remove the containers
kolla_docker:
@ -45,8 +39,7 @@
- item[2]['rc'] == 1
- inventory_hostname in groups[item[0]['group']]
with_together:
- [{ name: glance_api, group: glance-api },
{ name: glance_registry, group: glance-registry }]
- "{{ glance_service_groups }}"
- container_envs.results
- check_results.results
@ -63,7 +56,6 @@
- item[2]['rc'] == 1
- inventory_hostname in groups[item[0]['group']]
with_together:
- [{ name: glance_api, group: glance-api },
{ name: glance_registry, group: glance-registry }]
- "{{ glance_service_groups }}"
- container_envs.results
- check_results.results