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" 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 # Ceph

View File

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

View File

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