Merge "Optimize reconfiguration for panko"
This commit is contained in:
commit
17cc31ec73
@ -1,6 +1,18 @@
|
|||||||
---
|
---
|
||||||
project_name: "panko"
|
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
|
# 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
|
- name: Running panko bootstrap container
|
||||||
|
vars:
|
||||||
|
panko_api: "{{ panko_services['panko-api'] }}"
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "start_container"
|
action: "start_container"
|
||||||
common_options: "{{ docker_common_options }}"
|
common_options: "{{ docker_common_options }}"
|
||||||
@ -8,14 +10,11 @@
|
|||||||
KOLLA_BOOTSTRAP:
|
KOLLA_BOOTSTRAP:
|
||||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||||
PANKO_DATABASE_TYPE: "{{ panko_database_type }}"
|
PANKO_DATABASE_TYPE: "{{ panko_database_type }}"
|
||||||
image: "{{ panko_api_image_full }}"
|
image: "{{ panko_api.image }}"
|
||||||
labels:
|
labels:
|
||||||
BOOTSTRAP:
|
BOOTSTRAP:
|
||||||
name: "bootstrap_panko"
|
name: "bootstrap_panko"
|
||||||
restart_policy: "never"
|
restart_policy: "never"
|
||||||
volumes:
|
volumes: "{{ panko_api.volumes }}"
|
||||||
- "{{ node_config_directory }}/panko-api/:{{ container_config_directory }}/:ro"
|
|
||||||
- "/etc/localtime:/etc/localtime:ro"
|
|
||||||
- "kolla_logs:/var/log/kolla/"
|
|
||||||
run_once: True
|
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
|
- 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:
|
||||||
- "panko-api"
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ panko_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: panko_config_jsons
|
||||||
- "panko-api"
|
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
|
- name: Copying over panko.conf
|
||||||
merge_configs:
|
merge_configs:
|
||||||
vars:
|
vars:
|
||||||
service_name: "{{ item }}"
|
service_name: "{{ item.key }}"
|
||||||
sources:
|
sources:
|
||||||
- "{{ role_path }}/templates/panko.conf.j2"
|
- "{{ role_path }}/templates/panko.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 }}/panko.conf"
|
- "{{ node_custom_config }}/panko.conf"
|
||||||
- "{{ node_custom_config }}/panko/{{ item }}.conf"
|
- "{{ node_custom_config }}/panko/{{ item.key }}.conf"
|
||||||
- "{{ node_custom_config }}/panko/{{ inventory_hostname }}/{{ item }}.conf"
|
- "{{ node_custom_config }}/panko/{{ inventory_hostname }}/{{ item.key }}.conf"
|
||||||
dest: "{{ node_config_directory }}/{{ item }}/panko.conf"
|
dest: "{{ node_config_directory }}/{{ item.key }}/panko.conf"
|
||||||
with_items:
|
register: panko_confs
|
||||||
- "panko-api"
|
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
|
- name: Copying over wsgi-panko files for services
|
||||||
|
vars:
|
||||||
|
service: "{{ panko_services['panko-api']}}"
|
||||||
template:
|
template:
|
||||||
src: "wsgi-panko.conf.j2"
|
src: "wsgi-panko.conf.j2"
|
||||||
dest: "{{ node_config_directory }}/{{ item }}/wsgi-panko.conf"
|
dest: "{{ node_config_directory }}/{{ item }}/wsgi-panko.conf"
|
||||||
|
register: panko_wsgi
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
with_items:
|
with_items:
|
||||||
- "panko-api"
|
- "panko-api"
|
||||||
|
notify:
|
||||||
|
- Restart panko-api container
|
||||||
|
|
||||||
- name: Check if policies shall be overwritten
|
- name: Check if policies shall be overwritten
|
||||||
local_action: stat path="{{ node_custom_config }}/panko/policy.json"
|
local_action: stat path="{{ node_custom_config }}/panko/policy.json"
|
||||||
@ -44,8 +64,28 @@
|
|||||||
- name: Copying over existing policy.json
|
- name: Copying over existing policy.json
|
||||||
template:
|
template:
|
||||||
src: "{{ node_custom_config }}/panko/policy.json"
|
src: "{{ node_custom_config }}/panko/policy.json"
|
||||||
dest: "{{ node_config_directory }}/{{ item }}/policy.json"
|
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
|
||||||
with_items:
|
register: panko_policy_jsons
|
||||||
- "panko-api"
|
|
||||||
when:
|
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
|
- include: bootstrap.yml
|
||||||
when: inventory_hostname in groups['panko-api']
|
when: inventory_hostname in groups['panko-api']
|
||||||
|
|
||||||
- include: start.yml
|
- name: Flush handlers
|
||||||
when: inventory_hostname in groups['panko-api']
|
meta: flush_handlers
|
||||||
|
@ -1,64 +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: 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 }}"
|
|
||||||
|
@ -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: bootstrap_service.yml
|
||||||
|
|
||||||
- include: start.yml
|
- name: Flush handlers
|
||||||
|
meta: flush_handlers
|
||||||
|
Loading…
Reference in New Issue
Block a user