Optimize reconfiguration for panko
Co-Authored-By: caoyuan <cao.yuan@99cloud.net> Change-Id: I9ee4345b3cd5bdeda859fda07f972b80f3e20689 Partially-implements: blueprint better-reconfigure
This commit is contained in:
parent
7f3d7a30d9
commit
edb842e10a
@ -1,6 +1,18 @@
|
||||
---
|
||||
project_name: "panko"
|
||||
|
||||
panko_services:
|
||||
panko-api:
|
||||
container_name: panko_api
|
||||
group: panko-api
|
||||
enabled: true
|
||||
image: "{{ panko_api_image_full }}"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/panko-api/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
|
||||
|
||||
####################
|
||||
# Database
|
||||
####################
|
||||
|
24
ansible/roles/panko/handlers/main.yml
Normal file
24
ansible/roles/panko/handlers/main.yml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
- name: Restart panko-api container
|
||||
vars:
|
||||
service_name: "panko-api"
|
||||
service: "{{ panko_services[service_name] }}"
|
||||
config_json: "{{ panko_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
panko_conf: "{{ panko_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
policy_json: "{{ panko_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
panko_api_container: "{{ check_panko_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 panko_conf.changed | bool
|
||||
or panko_wsgi.changed | bool
|
||||
or policy_json.changed | bool
|
||||
or panko_api_container.changed | bool
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
- name: Running panko bootstrap container
|
||||
vars:
|
||||
panko_api: "{{ panko_services['panko-api'] }}"
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
@ -8,14 +10,11 @@
|
||||
KOLLA_BOOTSTRAP:
|
||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||
PANKO_DATABASE_TYPE: "{{ panko_database_type }}"
|
||||
image: "{{ panko_api_image_full }}"
|
||||
image: "{{ panko_api.image }}"
|
||||
labels:
|
||||
BOOTSTRAP:
|
||||
name: "bootstrap_panko"
|
||||
restart_policy: "never"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/panko-api/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
volumes: "{{ panko_api.volumes }}"
|
||||
run_once: True
|
||||
delegate_to: "{{ groups['panko-api'][0] }}"
|
||||
delegate_to: "{{ groups[panko_api.group][0] }}"
|
||||
|
@ -1,41 +1,61 @@
|
||||
---
|
||||
- name: Ensuring config directories exist
|
||||
file:
|
||||
path: "{{ node_config_directory }}/{{ item }}"
|
||||
path: "{{ node_config_directory }}/{{ item.key }}"
|
||||
state: "directory"
|
||||
recurse: yes
|
||||
with_items:
|
||||
- "panko-api"
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ panko_services }}"
|
||||
|
||||
- name: Copying over config.json files for services
|
||||
template:
|
||||
src: "{{ item }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/config.json"
|
||||
with_items:
|
||||
- "panko-api"
|
||||
src: "{{ item.key }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
|
||||
register: panko_config_jsons
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ panko_services }}"
|
||||
notify:
|
||||
- Restart panko-api container
|
||||
|
||||
- name: Copying over panko.conf
|
||||
merge_configs:
|
||||
vars:
|
||||
service_name: "{{ item }}"
|
||||
service_name: "{{ item.key }}"
|
||||
sources:
|
||||
- "{{ role_path }}/templates/panko.conf.j2"
|
||||
- "{{ node_custom_config }}/global.conf"
|
||||
- "{{ node_custom_config }}/database.conf"
|
||||
- "{{ node_custom_config }}/messaging.conf"
|
||||
- "{{ node_custom_config }}/panko.conf"
|
||||
- "{{ node_custom_config }}/panko/{{ item }}.conf"
|
||||
- "{{ node_custom_config }}/panko/{{ inventory_hostname }}/{{ item }}.conf"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/panko.conf"
|
||||
with_items:
|
||||
- "panko-api"
|
||||
- "{{ node_custom_config }}/panko/{{ item.key }}.conf"
|
||||
- "{{ node_custom_config }}/panko/{{ inventory_hostname }}/{{ item.key }}.conf"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/panko.conf"
|
||||
register: panko_confs
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ panko_services }}"
|
||||
notify:
|
||||
- Restart panko-api container
|
||||
|
||||
- name: Copying over wsgi-panko files for services
|
||||
vars:
|
||||
service: "{{ panko_services['panko-api']}}"
|
||||
template:
|
||||
src: "wsgi-panko.conf.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/wsgi-panko.conf"
|
||||
register: panko_wsgi
|
||||
when:
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
with_items:
|
||||
- "panko-api"
|
||||
notify:
|
||||
- Restart panko-api container
|
||||
|
||||
- name: Check if policies shall be overwritten
|
||||
local_action: stat path="{{ node_custom_config }}/panko/policy.json"
|
||||
@ -44,8 +64,28 @@
|
||||
- name: Copying over existing policy.json
|
||||
template:
|
||||
src: "{{ node_custom_config }}/panko/policy.json"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/policy.json"
|
||||
with_items:
|
||||
- "panko-api"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
|
||||
register: panko_policy_jsons
|
||||
when:
|
||||
panko_policy.stat.exists
|
||||
- panko_policy.stat.exists
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ panko_services }}"
|
||||
notify:
|
||||
- Restart panko-api container
|
||||
|
||||
- name: Check panko 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_panko_containers
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ panko_services }}"
|
||||
notify:
|
||||
- Restart panko-api container
|
||||
|
@ -8,5 +8,5 @@
|
||||
- include: bootstrap.yml
|
||||
when: inventory_hostname in groups['panko-api']
|
||||
|
||||
- include: start.yml
|
||||
when: inventory_hostname in groups['panko-api']
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
@ -1,64 +1,2 @@
|
||||
---
|
||||
- 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: panko_api, group: panko-api }
|
||||
|
||||
- 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: panko_api, group: panko-api }
|
||||
|
||||
# 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: panko_api, group: panko-api }
|
||||
|
||||
- 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: panko_api, group: panko-api }]
|
||||
- "{{ 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: panko_api, group: panko-api }]
|
||||
- "{{ container_envs.results }}"
|
||||
- "{{ check_results.results }}"
|
||||
- include: deploy.yml
|
||||
|
@ -1,12 +0,0 @@
|
||||
---
|
||||
- name: Starting panko-api container
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ panko_api_image_full }}"
|
||||
name: "panko_api"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/panko-api/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
when: inventory_hostname in groups['panko-api']
|
@ -3,4 +3,5 @@
|
||||
|
||||
- include: bootstrap_service.yml
|
||||
|
||||
- include: start.yml
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
Loading…
Reference in New Issue
Block a user