Merge "Optimize reconfigure action for memcached"

This commit is contained in:
Jenkins 2017-01-04 21:39:02 +00:00 committed by Gerrit Code Review
commit 3513ab825d
8 changed files with 49 additions and 81 deletions

View File

@ -1,6 +1,17 @@
---
project_name: "memcached"
memcached_services:
memcached:
container_name: "memcached"
image: "{{ memcached_image_full }}"
enabled: true
group: "memcached"
volumes:
- "{{ node_config_directory }}/memcached/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
####################
# Docker
####################

View File

@ -0,0 +1,14 @@
- name: Restart memcached container
vars:
service: "{{ memcached_services.memcached }}"
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ service.image }}"
name: "{{ service.container_name }}"
volumes: "{{ service.volumes }}"
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
- memcached_config_json.changed | bool
or check_memcached_container.changed | bool

View File

@ -11,5 +11,22 @@
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
register: memcached_config_json
with_items:
- "memcached"
notify: Restart memcached container
- name: Check memcached container
vars:
service: "{{ memcached_services.memcached }}"
kolla_docker:
action: "compare_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
volumes: "{{ service.volumes }}"
register: check_memcached_container
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
notify: Restart memcached container

View File

@ -1,4 +1,2 @@
---
- include: config.yml
- include: start.yml

View File

@ -1,7 +1,11 @@
---
- name: Pulling memcached image
vars:
service: "{{ memcached_services.memcached }}"
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ memcached_image_full }}"
when: inventory_hostname in groups['memcached']
image: "{{ service.image }}"
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool

View File

@ -1,64 +0,0 @@
---
- name: Ensuring the containers up
kolla_docker:
name: "{{ item.name }}"
action: "get_container_state"
register: container_state
failed_when: container_state.Running == false
when: inventory_hostname in groups[item.group]
with_items:
- { name: memcached, group: memcached }
- include: config.yml
- name: Check the configs
command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check
changed_when: false
failed_when: false
register: check_results
when: inventory_hostname in groups[item.group]
with_items:
- { name: memcached, group: memcached }
# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS'
# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE',
# just remove the container and start again
- name: Containers config strategy
kolla_docker:
name: "{{ item.name }}"
action: "get_container_env"
register: container_envs
when: inventory_hostname in groups[item.group]
with_items:
- { name: memcached, group: memcached }
- name: Remove the containers
kolla_docker:
name: "{{ item[0]['name'] }}"
action: "remove_container"
register: remove_containers
when:
- config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
- item[2]['rc'] == 1
- inventory_hostname in groups[item[0]['group']]
with_together:
- [{ name: memcached, group: memcached }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
- include: start.yml
when: remove_containers.changed
- name: Restart containers
kolla_docker:
name: "{{ item[0]['name'] }}"
action: "restart_container"
when:
- config_strategy == 'COPY_ALWAYS'
- item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
- item[2]['rc'] == 1
- inventory_hostname in groups[item[0]['group']]
with_together:
- [{ name: memcached, group: memcached }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"

View File

@ -0,0 +1 @@
deploy.yml

View File

@ -1,11 +0,0 @@
---
- name: Starting memcached container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ memcached_image_full }}"
name: "memcached"
volumes:
- "{{ node_config_directory }}/memcached/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
when: inventory_hostname in groups['memcached']

View File

@ -1,4 +1,2 @@
---
- include: config.yml
- include: start.yml