Optimize reconfigure action for trove
Co-Authored-By: Mauricio Lima <mauriciolimab@gmail.com> Change-Id: Icbf70b0cb242dbd705e8794369b7f8d32a43c25f Partially-implements: blueprint better-reconfigure
This commit is contained in:
parent
83d99ecf0c
commit
1210720a95
@ -1,6 +1,39 @@
|
|||||||
---
|
---
|
||||||
project_name: "trove"
|
project_name: "trove"
|
||||||
|
|
||||||
|
trove_services:
|
||||||
|
trove-api:
|
||||||
|
container_name: trove_api
|
||||||
|
group: trove-api
|
||||||
|
enabled: true
|
||||||
|
image: "{{ trove_api_image_full }}"
|
||||||
|
volumes:
|
||||||
|
- "{{ node_config_directory }}/trove-api/:{{ container_config_directory }}/:ro"
|
||||||
|
- "/etc/localtime:/etc/localtime:ro"
|
||||||
|
- "kolla_logs:/var/log/kolla/"
|
||||||
|
- "trove:/var/lib/trove/"
|
||||||
|
trove-conductor:
|
||||||
|
container_name: trove_conductor
|
||||||
|
group: trove-conductor
|
||||||
|
enabled: true
|
||||||
|
image: "{{ trove_conductor_image_full }}"
|
||||||
|
volumes:
|
||||||
|
- "{{ node_config_directory }}/trove-conductor/:{{ container_config_directory }}/:ro"
|
||||||
|
- "/etc/localtime:/etc/localtime:ro"
|
||||||
|
- "kolla_logs:/var/log/kolla/"
|
||||||
|
- "trove:/var/lib/trove/"
|
||||||
|
trove-taskmanager:
|
||||||
|
container_name: trove_taskmanager
|
||||||
|
group: trove-taskmanager
|
||||||
|
enabled: true
|
||||||
|
image: "{{ trove_taskmanager_image_full }}"
|
||||||
|
volumes:
|
||||||
|
- "{{ node_config_directory }}/trove-taskmanager/:{{ container_config_directory }}/:ro"
|
||||||
|
- "/etc/localtime:/etc/localtime:ro"
|
||||||
|
- "kolla_logs:/var/log/kolla/"
|
||||||
|
- "trove:/var/lib/trove/"
|
||||||
|
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Database
|
# Database
|
||||||
####################
|
####################
|
||||||
|
67
ansible/roles/trove/handlers/main.yml
Normal file
67
ansible/roles/trove/handlers/main.yml
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
---
|
||||||
|
- name: Restart trove-api container
|
||||||
|
vars:
|
||||||
|
service_name: "trove-api"
|
||||||
|
service: "{{ trove_services[service_name] }}"
|
||||||
|
config_json: "{{ trove_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
trove_conf: "{{ trove_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
trove_api_container: "{{ check_trove_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
kolla_docker:
|
||||||
|
action: "recreate_or_restart_container"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
name: "{{ service.container_name }}"
|
||||||
|
image: "{{ service.image }}"
|
||||||
|
volumes: "{{ service.volumes }}"
|
||||||
|
when:
|
||||||
|
- action != "config"
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
|
- config_json.changed | bool
|
||||||
|
or trove_conf.changed | bool
|
||||||
|
or trove_api_container.changed | bool
|
||||||
|
|
||||||
|
- name: Restart trove-conductor container
|
||||||
|
vars:
|
||||||
|
service_name: "trove-conductor"
|
||||||
|
service: "{{ trove_services[service_name] }}"
|
||||||
|
config_json: "{{ trove_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
conf_file: "{{ trove_conf_file.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
trove_conf: "{{ trove_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
trove_conductor_container: "{{ check_trove_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
kolla_docker:
|
||||||
|
action: "recreate_or_restart_container"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
name: "{{ service.container_name }}"
|
||||||
|
image: "{{ service.image }}"
|
||||||
|
volumes: "{{ service.volumes }}"
|
||||||
|
when:
|
||||||
|
- action != "config"
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
|
- config_json.changed | bool
|
||||||
|
or conf_file.changed | bool
|
||||||
|
or trove_conf.changed | bool
|
||||||
|
or trove_conductor_container.changed | bool
|
||||||
|
|
||||||
|
- name: Restart trove-taskmanager container
|
||||||
|
vars:
|
||||||
|
service_name: "trove-taskmanager"
|
||||||
|
service: "{{ trove_services[service_name] }}"
|
||||||
|
config_json: "{{ trove_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
conf_file: "{{ trove_conf_file.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
trove_conf: "{{ trove_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
trove_taskmanager_container: "{{ check_trove_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
kolla_docker:
|
||||||
|
action: "recreate_or_restart_container"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
name: "{{ service.container_name }}"
|
||||||
|
image: "{{ service.image }}"
|
||||||
|
volumes: "{{ service.volumes }}"
|
||||||
|
when:
|
||||||
|
- action != "config"
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
|
- config_json.changed | bool
|
||||||
|
or conf_file.changed | bool
|
||||||
|
or trove_conf.changed | bool
|
||||||
|
or trove_taskmanager_container.changed | bool
|
@ -1,5 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Running trove bootstrap container
|
- name: Running trove bootstrap container
|
||||||
|
vars:
|
||||||
|
trove_api: "{{ trove_services['trove-api'] }}"
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "start_container"
|
action: "start_container"
|
||||||
common_options: "{{ docker_common_options }}"
|
common_options: "{{ docker_common_options }}"
|
||||||
@ -7,15 +9,11 @@
|
|||||||
environment:
|
environment:
|
||||||
KOLLA_BOOTSTRAP:
|
KOLLA_BOOTSTRAP:
|
||||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||||
image: "{{ trove_api_image_full }}"
|
image: "{{ trove_api.image }}"
|
||||||
labels:
|
labels:
|
||||||
BOOTSTRAP:
|
BOOTSTRAP:
|
||||||
name: "bootstrap_trove"
|
name: "bootstrap_trove"
|
||||||
restart_policy: "never"
|
restart_policy: "never"
|
||||||
volumes:
|
volumes: "{{ trove_api.volumes }}"
|
||||||
- "{{ node_config_directory }}/trove-api/:{{ container_config_directory }}/:ro"
|
|
||||||
- "/etc/localtime:/etc/localtime:ro"
|
|
||||||
- "kolla_logs:/var/log/kolla/"
|
|
||||||
- "trove:/var/lib/trove/"
|
|
||||||
run_once: True
|
run_once: True
|
||||||
delegate_to: "{{ groups['trove-api'][0] }}"
|
delegate_to: "{{ groups[trove_api.group][0] }}"
|
||||||
|
@ -1,45 +1,73 @@
|
|||||||
---
|
---
|
||||||
- name: Ensuring config directories exist
|
- name: Ensuring config directories exist
|
||||||
file:
|
file:
|
||||||
path: "{{ node_config_directory }}/{{ item }}"
|
path: "{{ node_config_directory }}/{{ item.key }}"
|
||||||
state: "directory"
|
state: "directory"
|
||||||
recurse: yes
|
recurse: yes
|
||||||
with_items:
|
when:
|
||||||
- "trove-conductor"
|
- inventory_hostname in groups[item.value.group]
|
||||||
- "trove-api"
|
- item.value.enabled | bool
|
||||||
- "trove-taskmanager"
|
with_dict: "{{ trove_services }}"
|
||||||
|
|
||||||
- name: Copying over config.json files for services
|
- name: Copying over config.json files for services
|
||||||
template:
|
template:
|
||||||
src: "{{ item }}.json.j2"
|
src: "{{ item.key }}.json.j2"
|
||||||
dest: "{{ node_config_directory }}/{{ item }}/config.json"
|
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
|
||||||
with_items:
|
register: trove_config_jsons
|
||||||
- "trove-conductor"
|
when:
|
||||||
- "trove-api"
|
- inventory_hostname in groups[item.value.group]
|
||||||
- "trove-taskmanager"
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ trove_services }}"
|
||||||
|
notify:
|
||||||
|
- "Restart {{ item.key }} container"
|
||||||
|
|
||||||
- name: Copying over trove conf files
|
- name: Copying over trove conf files
|
||||||
template:
|
template:
|
||||||
src: "{{ item }}.conf.j2"
|
src: "{{ item.key }}.conf.j2"
|
||||||
dest: "{{ node_config_directory }}/{{ item }}/{{ item }}.conf"
|
dest: "{{ node_config_directory }}/{{ item.key }}/{{ item.key }}.conf"
|
||||||
with_items:
|
register: trove_conf_file
|
||||||
- "trove-conductor"
|
when:
|
||||||
- "trove-taskmanager"
|
- item.key in [ "trove-conductor", "trove-taskmanager" ]
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ trove_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart trove-conductor container
|
||||||
|
- Restart trove-taskmanager container
|
||||||
|
|
||||||
- name: Copying over trove.conf
|
- name: Copying over trove.conf
|
||||||
merge_configs:
|
merge_configs:
|
||||||
vars:
|
vars:
|
||||||
service_name: "{{ item }}"
|
service_name: "{{ item.key }}"
|
||||||
sources:
|
sources:
|
||||||
- "{{ role_path }}/templates/trove.conf.j2"
|
- "{{ role_path }}/templates/trove.conf.j2"
|
||||||
- "{{ node_custom_config }}/global.conf"
|
- "{{ node_custom_config }}/global.conf"
|
||||||
- "{{ node_custom_config }}/database.conf"
|
- "{{ node_custom_config }}/database.conf"
|
||||||
- "{{ node_custom_config }}/messaging.conf"
|
- "{{ node_custom_config }}/messaging.conf"
|
||||||
- "{{ node_custom_config }}/trove.conf"
|
- "{{ node_custom_config }}/trove.conf"
|
||||||
- "{{ node_custom_config }}/trove/{{ item }}.conf"
|
- "{{ node_custom_config }}/trove/{{ item.key }}.conf"
|
||||||
- "{{ node_custom_config }}/trove/{{ inventory_hostname }}/trove.conf"
|
- "{{ node_custom_config }}/trove/{{ inventory_hostname }}/trove.conf"
|
||||||
dest: "{{ node_config_directory }}/{{ item }}/trove.conf"
|
dest: "{{ node_config_directory }}/{{ item.key }}/trove.conf"
|
||||||
with_items:
|
register: trove_confs
|
||||||
- "trove-conductor"
|
when:
|
||||||
- "trove-api"
|
- inventory_hostname in groups[item.value.group]
|
||||||
- "trove-taskmanager"
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ trove_services }}"
|
||||||
|
notify:
|
||||||
|
- "Restart {{ item.key }} container"
|
||||||
|
|
||||||
|
- name: Check trove containers
|
||||||
|
kolla_docker:
|
||||||
|
action: "compare_container"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
name: "{{ item.value.container_name }}"
|
||||||
|
image: "{{ item.value.image }}"
|
||||||
|
volumes: "{{ item.value.volumes }}"
|
||||||
|
register: check_trove_containers
|
||||||
|
when:
|
||||||
|
- action != "config"
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ trove_services }}"
|
||||||
|
notify:
|
||||||
|
- "Restart {{ item.key }} container"
|
||||||
|
@ -10,7 +10,5 @@
|
|||||||
- include: bootstrap.yml
|
- include: bootstrap.yml
|
||||||
when: inventory_hostname in groups['trove-api']
|
when: inventory_hostname in groups['trove-api']
|
||||||
|
|
||||||
- include: start.yml
|
- name: Flush handlers
|
||||||
when: inventory_hostname in groups['trove-api'] or
|
meta: flush_handlers
|
||||||
inventory_hostname in groups['trove-conductor'] or
|
|
||||||
inventory_hostname in groups['trove-taskmanager']
|
|
||||||
|
@ -1,21 +1,10 @@
|
|||||||
---
|
---
|
||||||
- name: Pulling trove-api image
|
- name: Pulling trove images
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "pull_image"
|
action: "pull_image"
|
||||||
common_options: "{{ docker_common_options }}"
|
common_options: "{{ docker_common_options }}"
|
||||||
image: "{{ trove_api_image_full }}"
|
image: "{{ item.value.image }}"
|
||||||
when: inventory_hostname in groups['trove-api']
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
- name: Pulling trove-conductor image
|
- item.value.enabled | bool
|
||||||
kolla_docker:
|
with_dict: "{{ trove_services }}"
|
||||||
action: "pull_image"
|
|
||||||
common_options: "{{ docker_common_options }}"
|
|
||||||
image: "{{ trove_conductor_image_full }}"
|
|
||||||
when: inventory_hostname in groups['trove-conductor']
|
|
||||||
|
|
||||||
- name: Pulling trove-taskmanager image
|
|
||||||
kolla_docker:
|
|
||||||
action: "pull_image"
|
|
||||||
common_options: "{{ docker_common_options }}"
|
|
||||||
image: "{{ trove_taskmanager_image_full }}"
|
|
||||||
when: inventory_hostname in groups['trove-taskmanager']
|
|
||||||
|
@ -1,74 +1,2 @@
|
|||||||
---
|
---
|
||||||
- name: Ensuring the containers up
|
- include: deploy.yml
|
||||||
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: trove_api, group: trove-api }
|
|
||||||
- { name: trove_conductor, group: trove-conductor }
|
|
||||||
- { name: trove_taskmanager, group: trove-taskmanager }
|
|
||||||
|
|
||||||
- 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: trove_api, group: trove-api }
|
|
||||||
- { name: trove_conductor, group: trove-conductor }
|
|
||||||
- { name: trove_taskmanager, group: trove-taskmanager }
|
|
||||||
|
|
||||||
# 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: trove_api, group: trove-api }
|
|
||||||
- { name: trove_conductor, group: trove-conductor }
|
|
||||||
- { name: trove_taskmanager, group: trove-taskmanager }
|
|
||||||
|
|
||||||
- name: Remove the containers
|
|
||||||
kolla_docker:
|
|
||||||
name: "{{ item[0]['name'] }}"
|
|
||||||
action: "remove_container"
|
|
||||||
register: remove_containers
|
|
||||||
when:
|
|
||||||
- inventory_hostname in groups[item[0]['group']]
|
|
||||||
- config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
|
|
||||||
- item[2]['rc'] == 1
|
|
||||||
with_together:
|
|
||||||
- [{ name: trove_api, group: trove-api },
|
|
||||||
{ name: trove_conductor, group: trove-conductor },
|
|
||||||
{ name: trove_taskmanager, group: trove-taskmanager }]
|
|
||||||
- "{{ 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:
|
|
||||||
- inventory_hostname in groups[item[0]['group']]
|
|
||||||
- config_strategy == 'COPY_ALWAYS'
|
|
||||||
- item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
|
|
||||||
- item[2]['rc'] == 1
|
|
||||||
with_together:
|
|
||||||
- [{ name: trove_api, group: trove-api },
|
|
||||||
{ name: trove_conductor, group: trove-conductor },
|
|
||||||
{ name: trove_taskmanager, group: trove-taskmanager }]
|
|
||||||
- "{{ container_envs.results }}"
|
|
||||||
- "{{ check_results.results }}"
|
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Starting trove-api container
|
|
||||||
kolla_docker:
|
|
||||||
action: "start_container"
|
|
||||||
common_options: "{{ docker_common_options }}"
|
|
||||||
image: "{{ trove_api_image_full }}"
|
|
||||||
name: "trove_api"
|
|
||||||
volumes:
|
|
||||||
- "{{ node_config_directory }}/trove-api/:{{ container_config_directory }}/:ro"
|
|
||||||
- "/etc/localtime:/etc/localtime:ro"
|
|
||||||
- "kolla_logs:/var/log/kolla/"
|
|
||||||
when: inventory_hostname in groups['trove-api']
|
|
||||||
|
|
||||||
- name: Starting trove-conductor container
|
|
||||||
kolla_docker:
|
|
||||||
action: "start_container"
|
|
||||||
common_options: "{{ docker_common_options }}"
|
|
||||||
image: "{{ trove_conductor_image_full }}"
|
|
||||||
name: "trove_conductor"
|
|
||||||
volumes:
|
|
||||||
- "{{ node_config_directory }}/trove-conductor/:{{ container_config_directory }}/:ro"
|
|
||||||
- "/etc/localtime:/etc/localtime:ro"
|
|
||||||
- "kolla_logs:/var/log/kolla/"
|
|
||||||
- "trove:/var/lib/trove/"
|
|
||||||
when: inventory_hostname in groups['trove-conductor']
|
|
||||||
|
|
||||||
- name: Starting trove-taskmanager container
|
|
||||||
kolla_docker:
|
|
||||||
action: "start_container"
|
|
||||||
common_options: "{{ docker_common_options }}"
|
|
||||||
image: "{{ trove_taskmanager_image_full }}"
|
|
||||||
name: "trove_taskmanager"
|
|
||||||
volumes:
|
|
||||||
- "{{ node_config_directory }}/trove-taskmanager/:{{ container_config_directory }}/:ro"
|
|
||||||
- "/etc/localtime:/etc/localtime:ro"
|
|
||||||
- "kolla_logs:/var/log/kolla/"
|
|
||||||
- "trove:/var/lib/trove/"
|
|
||||||
when: inventory_hostname in groups['trove-taskmanager']
|
|
@ -3,4 +3,5 @@
|
|||||||
|
|
||||||
- include: bootstrap_service.yml
|
- include: bootstrap_service.yml
|
||||||
|
|
||||||
- include: start.yml
|
- name: Flush handlers
|
||||||
|
meta: flush_handlers
|
||||||
|
Loading…
Reference in New Issue
Block a user