Optimize reconfigure action for memcached
Change-Id: Ia127e29fd07bf01eb817e3d319d56f17854b09c9 Partically-implements: blueprint better-reconfigure
This commit is contained in:
parent
d37da2cfa9
commit
6e6327e822
@ -1,6 +1,17 @@
|
|||||||
---
|
---
|
||||||
project_name: "memcached"
|
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
|
# Docker
|
||||||
####################
|
####################
|
||||||
|
14
ansible/roles/memcached/handlers/main.yml
Normal file
14
ansible/roles/memcached/handlers/main.yml
Normal 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
|
@ -11,5 +11,22 @@
|
|||||||
template:
|
template:
|
||||||
src: "{{ item }}.json.j2"
|
src: "{{ item }}.json.j2"
|
||||||
dest: "{{ node_config_directory }}/{{ item }}/config.json"
|
dest: "{{ node_config_directory }}/{{ item }}/config.json"
|
||||||
|
register: memcached_config_json
|
||||||
with_items:
|
with_items:
|
||||||
- "memcached"
|
- "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
|
||||||
|
@ -1,4 +1,2 @@
|
|||||||
---
|
---
|
||||||
- include: config.yml
|
- include: config.yml
|
||||||
|
|
||||||
- include: start.yml
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
---
|
---
|
||||||
- name: Pulling memcached image
|
- name: Pulling memcached image
|
||||||
|
vars:
|
||||||
|
service: "{{ memcached_services.memcached }}"
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "pull_image"
|
action: "pull_image"
|
||||||
common_options: "{{ docker_common_options }}"
|
common_options: "{{ docker_common_options }}"
|
||||||
image: "{{ memcached_image_full }}"
|
image: "{{ service.image }}"
|
||||||
when: inventory_hostname in groups['memcached']
|
when:
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
|
@ -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 }}"
|
|
1
ansible/roles/memcached/tasks/reconfigure.yml
Symbolic link
1
ansible/roles/memcached/tasks/reconfigure.yml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
deploy.yml
|
@ -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']
|
|
@ -1,4 +1,2 @@
|
|||||||
---
|
---
|
||||||
- include: config.yml
|
- include: config.yml
|
||||||
|
|
||||||
- include: start.yml
|
|
||||||
|
Loading…
Reference in New Issue
Block a user