Optimize reconfiguration for senlin
Change-Id: I6516db6e1cb0ccd3de6c525e686e041619f83a36 Partially-implements: blueprint better-reconfigure
This commit is contained in:
parent
2d32083a27
commit
927c89571f
@ -1,6 +1,26 @@
|
||||
---
|
||||
project_name: "senlin"
|
||||
|
||||
senlin_services:
|
||||
senlin-api:
|
||||
container_name: senlin_api
|
||||
group: senlin-api
|
||||
enabled: true
|
||||
image: "{{ senlin_api_image_full }}"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/senlin-api/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
senlin-engine:
|
||||
container_name: senlin_engine
|
||||
group: senlin-engine
|
||||
enabled: true
|
||||
image: "{{ senlin_engine_image_full }}"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/senlin-engine/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
|
||||
####################
|
||||
# Database
|
||||
####################
|
||||
|
44
ansible/roles/senlin/handlers/main.yml
Normal file
44
ansible/roles/senlin/handlers/main.yml
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
- name: Restart senlin-api container
|
||||
vars:
|
||||
service_name: "senlin-api"
|
||||
service: "{{ senlin_services[service_name] }}"
|
||||
config_json: "{{ senlin_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
senlin_conf: "{{ senlin_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
policy_json: "{{ senlin_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
senlin_api_container: "{{ check_senlin_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:
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
- config_json.changed | bool
|
||||
or senlin_conf.changed | bool
|
||||
or policy_json.changed | bool
|
||||
or senlin_api_container.changed | bool
|
||||
|
||||
- name: Restart senlin-engine container
|
||||
vars:
|
||||
service_name: "senlin-engine"
|
||||
service: "{{ senlin_services[service_name] }}"
|
||||
config_json: "{{ senlin_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
senlin_conf: "{{ senlin_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
policy_json: "{{ senlin_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
senlin_engine_container: "{{ check_senlin_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:
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
- config_json.changed | bool
|
||||
or senlin_conf.changed | bool
|
||||
or policy_json.changed | bool
|
||||
or senlin_engine_container.changed | bool
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
- name: Running Senlin bootstrap container
|
||||
vars:
|
||||
senlin_api: "{{ senlin_services['senlin-api'] }}"
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
@ -7,14 +9,11 @@
|
||||
environment:
|
||||
KOLLA_BOOTSTRAP:
|
||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||
image: "{{ senlin_api_image_full }}"
|
||||
image: "{{ senlin_api.image }}"
|
||||
labels:
|
||||
BOOTSTRAP:
|
||||
name: "bootstrap_senlin"
|
||||
restart_policy: "never"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/senlin-api/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
volumes: "{{ senlin_api.volumes }}"
|
||||
run_once: True
|
||||
delegate_to: "{{ groups['senlin-api'][0] }}"
|
||||
delegate_to: "{{ groups[senlin_api.group][0] }}"
|
||||
|
@ -1,37 +1,46 @@
|
||||
---
|
||||
- name: Ensuring config directories exist
|
||||
file:
|
||||
path: "{{ node_config_directory }}/{{ item }}"
|
||||
path: "{{ node_config_directory }}/{{ item.key }}"
|
||||
state: "directory"
|
||||
recurse: yes
|
||||
with_items:
|
||||
- "senlin-api"
|
||||
- "senlin-engine"
|
||||
when: inventory_hostname in groups[item.value.group]
|
||||
with_dict: "{{ senlin_services }}"
|
||||
|
||||
- name: Copying over config.json files for services
|
||||
template:
|
||||
src: "{{ item }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/config.json"
|
||||
with_items:
|
||||
- "senlin-api"
|
||||
- "senlin-engine"
|
||||
src: "{{ item.key }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
|
||||
register: senlin_config_jsons
|
||||
when:
|
||||
- item.value.enabled | bool
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
with_dict: "{{ senlin_services }}"
|
||||
notify:
|
||||
- Restart senlin-api container
|
||||
- Restart senlin-engine container
|
||||
|
||||
- name: Copying over senlin.conf
|
||||
merge_configs:
|
||||
vars:
|
||||
service_name: "{{ item }}"
|
||||
service_name: "{{ item.key }}"
|
||||
sources:
|
||||
- "{{ role_path }}/templates/senlin.conf.j2"
|
||||
- "{{ node_custom_config }}/global.conf"
|
||||
- "{{ node_custom_config }}/database.conf"
|
||||
- "{{ node_custom_config }}/messaging.conf"
|
||||
- "{{ node_custom_config }}/senlin.conf"
|
||||
- "{{ node_custom_config }}/senlin/{{ item }}.conf"
|
||||
- "{{ node_custom_config }}/senlin/{{ item.key }}.conf"
|
||||
- "{{ node_custom_config }}/senlin/{{ inventory_hostname }}/senlin.conf"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/senlin.conf"
|
||||
with_items:
|
||||
- "senlin-api"
|
||||
- "senlin-engine"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/senlin.conf"
|
||||
register: senlin_confs
|
||||
when:
|
||||
- item.value.enabled | bool
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
with_dict: "{{ senlin_services }}"
|
||||
notify:
|
||||
- Restart senlin-api container
|
||||
- Restart senlin-engine container
|
||||
|
||||
- name: Check if policies shall be overwritten
|
||||
local_action: stat path="{{ node_custom_config }}/senlin/policy.json"
|
||||
@ -40,9 +49,30 @@
|
||||
- name: Copying over existing policy.json
|
||||
template:
|
||||
src: "{{ node_custom_config }}/senlin/policy.json"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/policy.json"
|
||||
with_items:
|
||||
- "senlin-api"
|
||||
- "senlin-engine"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
|
||||
register: senlin_policy_jsons
|
||||
when:
|
||||
senlin_policy.stat.exists
|
||||
- senlin_policy.stat.exists
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ senlin_services }}"
|
||||
notify:
|
||||
- Restart senlin-api container
|
||||
- Restart senlin-engine container
|
||||
|
||||
- name: Check senlin 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_senlin_containers
|
||||
when:
|
||||
- action != 'genconfig'
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ senlin_services }}"
|
||||
notify:
|
||||
- Restart senlin-api container
|
||||
- Restart senlin-engine container
|
||||
|
@ -9,6 +9,5 @@
|
||||
- include: bootstrap.yml
|
||||
when: inventory_hostname in groups['senlin-api']
|
||||
|
||||
- include: start.yml
|
||||
when: inventory_hostname in groups['senlin-api'] or
|
||||
inventory_hostname in groups['senlin-engine']
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
@ -1,14 +1,10 @@
|
||||
---
|
||||
- name: Pulling senlin-api image
|
||||
- name: Pulling senlin images
|
||||
kolla_docker:
|
||||
action: "pull_image"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ senlin_api_image_full }}"
|
||||
when: inventory_hostname in groups['senlin-api']
|
||||
|
||||
- name: Pulling senlin-engine image
|
||||
kolla_docker:
|
||||
action: "pull_image"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ senlin_engine_image_full }}"
|
||||
when: inventory_hostname in groups['senlin-engine']
|
||||
image: "{{ item.value.image }}"
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ senlin_services }}"
|
||||
|
@ -1,66 +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: senlin_api, group: senlin-api }
|
||||
- { name: senlin_engine, group: senlin-engine }
|
||||
|
||||
- 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: senlin_api, group: senlin-api }
|
||||
- { name: senlin_engine, group: senlin-engine }
|
||||
|
||||
- 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: senlin_api, group: senlin-api }
|
||||
- { name: senlin_engine, group: senlin-engine }
|
||||
|
||||
- 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: senlin_api, group: senlin-api },
|
||||
{ name: senlin_engine, group: senlin-engine }]
|
||||
- "{{ 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: senlin_api, group: senlin-api },
|
||||
{ name: senlin_engine, group: senlin-engine }]
|
||||
- "{{ container_envs.results }}"
|
||||
- "{{ check_results.results }}"
|
||||
- include: deploy.yml
|
||||
|
@ -1,24 +0,0 @@
|
||||
---
|
||||
- name: Starting senlin-engine container
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ senlin_engine_image_full }}"
|
||||
name: "senlin_engine"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/senlin-engine/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
when: inventory_hostname in groups['senlin-engine']
|
||||
|
||||
- name: Starting senlin-api container
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ senlin_api_image_full }}"
|
||||
name: "senlin_api"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/senlin-api/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
when: inventory_hostname in groups['senlin-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