Optimize reconfiguration for murano

Change-Id: Ib5116e76a9a5c97571282225b8eaf480f120f9b1
Partially-implements: blueprint better-reconfigure
Co-Authored-By: ZhijunWei <wzj334965317@outlook.com>
This commit is contained in:
wu.chunyang 2018-04-09 22:37:01 +08:00 committed by ZhijunWei
parent e303c74e68
commit 3093f44ca3
8 changed files with 136 additions and 128 deletions

View File

@ -1,6 +1,29 @@
---
project_name: "murano"
murano_services:
murano-api:
container_name: murano_api
group: murano-api
enabled: true
image: "{{ murano_api_image_full }}"
volumes:
- "{{ node_config_directory }}/murano-engine/:{{ container_config_directory }}/:ro"
- "{{ kolla_dev_repos_directory ~ '/murano/murano:/var/lib/kolla/venv/lib/python2.7/site-packages/murano' if murano_dev_mode | bool else '' }}"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
murano-engine:
container_name: murano_engine
group: murano-engine
enabled: true
image: "{{ murano_engine_image_full }}"
volumes:
- "{{ node_config_directory }}/murano-api/:{{ container_config_directory }}/:ro"
- "{{ kolla_dev_repos_directory ~ '/murano/murano:/var/lib/kolla/venv/lib/python2.7/site-packages/murano' if murano_dev_mode | bool else '' }}"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
####################
# Database
####################
@ -15,14 +38,14 @@ murano_database_address: "{{ database_address }}:{{ database_port }}"
murano_install_type: "{{ kolla_install_type }}"
murano_tag: "{{ openstack_release }}"
murano_engine_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ murano_install_type }}-murano-engine"
murano_engine_tag: "{{ murano_tag }}"
murano_engine_image_full: "{{ murano_engine_image }}:{{ murano_engine_tag }}"
murano_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ murano_install_type }}-murano-api"
murano_api_tag: "{{ murano_tag }}"
murano_api_image_full: "{{ murano_api_image }}:{{ murano_api_tag }}"
murano_engine_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ murano_install_type }}-murano-engine"
murano_engine_tag: "{{ murano_tag }}"
murano_engine_image_full: "{{ murano_engine_image }}:{{ murano_engine_tag }}"
####################
# OpenStack

View File

@ -0,0 +1,47 @@
---
- name: Restart murano-api container
vars:
service_name: "murano-api"
service: "{{ murano_services[service_name] }}"
config_json: "{{ murano_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
murano_conf: "{{ murano_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ murano_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
murano_api_container: "{{ check_murano_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 murano_conf.changed | bool
or policy_overwriting.changed | bool
or murano_api_container.changed | bool
- name: Restart murano-engine container
vars:
service_name: "murano-engine"
service: "{{ murano_services[service_name] }}"
config_json: "{{ murano_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
murano_conf: "{{ murano_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ murano_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
murano_conductor_container: "{{ check_murano_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 }}"
privileged: "{{ service.privileged | default(False) }}"
volumes: "{{ service.volumes }}"
when:
- action != "config"
- inventory_hostname in groups[service.group]
- service.enabled | bool
- config_json.changed | bool
or murano_conf.changed | bool
or policy_overwriting.changed | bool
or murano_conductor_container.changed | bool

View File

@ -1,15 +1,16 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
with_items:
- "murano-api"
- "murano-engine"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ murano_services }}"
- name: Check if policies shall be overwritten
local_action: stat path="{{ item }}"
@ -30,38 +31,65 @@
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660"
become: true
with_items:
- "murano-api"
- "murano-engine"
register: murano_config_jsons
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ murano_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Copying over murano.conf
vars:
service_name: "{{ item }}"
service_name: "{{ item.key }}"
merge_configs:
sources:
- "{{ role_path }}/templates/murano.conf.j2"
- "{{ node_custom_config }}/global.conf"
- "{{ node_custom_config }}/murano.conf"
- "{{ node_custom_config }}/murano/{{ item }}.conf"
- "{{ node_custom_config }}/murano/{{ item.key }}.conf"
- "{{ node_custom_config }}/murano/{{ inventory_hostname }}/murano.conf"
dest: "{{ node_config_directory }}/{{ item }}/murano.conf"
dest: "{{ node_config_directory }}/{{ item.key }}/murano.conf"
mode: "0660"
become: true
with_items:
- "murano-api"
- "murano-engine"
register: murano_confs
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ murano_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Copying over existing policy file
template:
src: "{{ murano_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ murano_policy_file }}"
mode: "0660"
register: murano_policy_overwriting
with_items:
- "murano-api"
- "murano-engine"
when:
murano_policy_file is defined
- murano_policy_file is defined
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ murano_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Check murano 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_murano_containers
when:
- action != "config"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ murano_services }}"
notify:
- "Restart {{ item.key }} container"

View File

@ -15,6 +15,7 @@
- include: bootstrap.yml
when: inventory_hostname in groups['murano-api']
- include: start.yml
when: inventory_hostname in groups['murano-api'] or
inventory_hostname in groups['murano-engine']
- name: Flush handlers
meta: flush_handlers
- include: import_library_packages.yml

View File

@ -1,30 +1,4 @@
---
- name: Starting murano-engine container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ murano_engine_image_full }}"
name: "murano_engine"
volumes:
- "{{ node_config_directory }}/murano-engine/:{{ container_config_directory }}/:ro"
- "{{ kolla_dev_repos_directory ~ '/murano/murano:/var/lib/kolla/venv/lib/python2.7/site-packages/murano' if murano_dev_mode | bool else '' }}"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['murano-engine']
- name: Starting murano-api container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ murano_api_image_full }}"
name: "murano_api"
volumes:
- "{{ node_config_directory }}/murano-api/:{{ container_config_directory }}/:ro"
- "{{ kolla_dev_repos_directory ~ '/murano/murano:/var/lib/kolla/venv/lib/python2.7/site-packages/murano' if murano_dev_mode | bool else '' }}"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['murano-api']
- name: Waiting for Murano API service to be ready on first node
wait_for:
host: "{{ api_interface_address }}"

View File

@ -1,14 +1,10 @@
---
- name: Pulling murano-api image
- name: Pulling murano images
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ murano_api_image_full }}"
when: inventory_hostname in groups['murano-api']
- name: Pulling murano-engine image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ murano_engine_image_full }}"
when: inventory_hostname in groups['murano-engine']
image: "{{ item.value.image }}"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ murano_services }}"

View File

@ -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: murano_api, group: murano-api }
- { name: murano_engine, group: murano-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: murano_api, group: murano-api }
- { name: murano_engine, group: murano-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: murano_api, group: murano-api }
- { name: murano_engine, group: murano-engine }
- 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: murano_api, group: murano-api },
{ name: murano_engine, group: murano-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:
- 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: murano_api, group: murano-api },
{ name: murano_engine, group: murano-engine }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
- include: deploy.yml

View File

@ -5,4 +5,7 @@
- include: bootstrap_service.yml
- include: start.yml
- name: Flush handlers
meta: flush_handlers
- include: import_library_packages.yml