Skip to content
Snippets Groups Projects
Commit 1128072a authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review
Browse files

Merge "Optimize reconfiguration for heat"

parents a1a5f794 a755e7f0
No related branches found
No related tags found
No related merge requests found
--- ---
project_name: "heat" project_name: "heat"
heat_services:
heat-api:
container_name: heat_api
group: heat-api
enabled: true
image: "{{ heat_api_image_full }}"
volumes:
- "{{ node_config_directory }}/heat-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
heat-api-cfn:
container_name: heat_api_cfn
group: heat-api-cfn
enabled: true
image: "{{ heat_api_cfn_image_full }}"
volumes:
- "{{ node_config_directory }}/heat-api-cfn/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
heat-engine:
container_name: heat_engine
group: heat-engine
enabled: true
image: "{{ heat_engine_image_full }}"
volumes:
- "{{ node_config_directory }}/heat-engine/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
#################### ####################
# Database # Database
#################### ####################
......
---
- name: Restart heat-api container
vars:
service_name: "heat-api"
service: "{{ heat_services[service_name] }}"
config_json: "{{ heat_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
heat_conf: "{{ heat_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ heat_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
heat_api_container: "{{ check_heat_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 heat_conf.changed | bool
or policy_json.changed | bool
or heat_api_container.changed | bool
- name: Restart heat-api-cfn container
vars:
service_name: "heat-api-cfn"
service: "{{ heat_services[service_name] }}"
config_json: "{{ heat_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
heat_conf: "{{ heat_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ heat_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
heat_api_cfn_container: "{{ check_heat_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 heat_conf.changed | bool
or policy_json.changed | bool
or heat_api_cfn_container.changed | bool
- name: Restart heat-engine container
vars:
service_name: "heat-engine"
service: "{{ heat_services[service_name] }}"
config_json: "{{ heat_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
heat_conf: "{{ heat_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ heat_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
heat_engine_container: "{{ check_heat_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 heat_conf.changed | bool
or policy_json.changed | bool
or heat_engine_container.changed | bool
--- ---
- name: Running Heat bootstrap container - name: Running Heat bootstrap container
vars:
heat_api: "{{ heat_services['heat-api'] }}"
kolla_docker: kolla_docker:
action: "start_container" action: "start_container"
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
...@@ -13,14 +15,11 @@ ...@@ -13,14 +15,11 @@
OS_PASSWORD: "{{ openstack_auth.password }}" OS_PASSWORD: "{{ openstack_auth.password }}"
OS_PROJECT_NAME: "{{ openstack_auth.project_name }}" OS_PROJECT_NAME: "{{ openstack_auth.project_name }}"
HEAT_DOMAIN_ADMIN_PASSWORD: "{{ heat_domain_admin_password }}" HEAT_DOMAIN_ADMIN_PASSWORD: "{{ heat_domain_admin_password }}"
image: "{{ heat_api_image_full }}" image: "{{ heat_api.image }}"
labels: labels:
BOOTSTRAP: BOOTSTRAP:
name: "bootstrap_heat" name: "bootstrap_heat"
restart_policy: "never" restart_policy: "never"
volumes: volumes: "{{ heat_api.volumes }}"
- "{{ node_config_directory }}/heat-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
run_once: True run_once: True
delegate_to: "{{ groups['heat-api'][0] }}" delegate_to: "{{ groups[heat_api.group][0] }}"
--- ---
- 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: inventory_hostname in groups[item.value.group]
- "heat-api" with_dict: "{{ heat_services }}"
- "heat-api-cfn"
- "heat-engine"
- 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: heat_config_jsons
- "heat-api" when:
- "heat-api-cfn" - item.value.enabled | bool
- "heat-engine" - inventory_hostname in groups[item.value.group]
with_dict: "{{ heat_services }}"
notify:
- Restart heat-api container
- Restart heat-api-cfn container
- Restart heat-engine container
- name: Copying over the heat-engine environment file - name: Copying over the heat-engine environment file
template: template:
...@@ -28,20 +31,25 @@ ...@@ -28,20 +31,25 @@
- name: Copying over heat.conf - name: Copying over heat.conf
merge_configs: merge_configs:
vars: vars:
service_name: "{{ item }}" service_name: "{{ item.key }}"
sources: sources:
- "{{ role_path }}/templates/heat.conf.j2" - "{{ role_path }}/templates/heat.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 }}/heat.conf" - "{{ node_custom_config }}/heat.conf"
- "{{ node_custom_config }}/heat/{{ item }}.conf" - "{{ node_custom_config }}/heat/{{ item.key }}.conf"
- "{{ node_custom_config }}/heat/{{ inventory_hostname }}/heat.conf" - "{{ node_custom_config }}/heat/{{ inventory_hostname }}/heat.conf"
dest: "{{ node_config_directory }}/{{ item }}/heat.conf" dest: "{{ node_config_directory }}/{{ item.key }}/heat.conf"
with_items: register: heat_confs
- "heat-api" when:
- "heat-api-cfn" - item.value.enabled | bool
- "heat-engine" - inventory_hostname in groups[item.value.group]
with_dict: "{{ heat_services }}"
notify:
- Restart heat-api container
- Restart heat-api-cfn container
- Restart heat-engine container
- name: Check if policies shall be overwritten - name: Check if policies shall be overwritten
local_action: stat path="{{ node_custom_config }}/heat/policy.json" local_action: stat path="{{ node_custom_config }}/heat/policy.json"
...@@ -50,10 +58,30 @@ ...@@ -50,10 +58,30 @@
- name: Copying over existing policy.json - name: Copying over existing policy.json
template: template:
src: "{{ node_custom_config }}/heat/policy.json" src: "{{ node_custom_config }}/heat/policy.json"
dest: "{{ node_config_directory }}/{{ item }}/policy.json" dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
with_items: register: heat_policy_jsons
- "heat-api" when:
- "heat-api-cfn" - heat_policy.stat.exists
- "heat-engine" - inventory_hostname in groups[item.value.group]
with_dict: "{{ heat_services }}"
notify:
- Restart heat-api container
- Restart heat-api-cfn container
- Restart heat-engine container
- name: Check heat 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_heat_containers
when: when:
heat_policy.stat.exists - inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ heat_services }}"
notify:
- Restart heat-api container
- Restart heat-api-cfn container
- Restart heat-engine container
...@@ -10,7 +10,5 @@ ...@@ -10,7 +10,5 @@
- include: bootstrap.yml - include: bootstrap.yml
when: inventory_hostname in groups['heat-api'] when: inventory_hostname in groups['heat-api']
- include: start.yml - name: Flush handlers
when: inventory_hostname in groups['heat-api'] or meta: flush_handlers
inventory_hostname in groups['heat-api-cfn'] or
inventory_hostname in groups['heat-engine']
--- ---
- name: Pulling heat-api image - name: Pulling heat images
kolla_docker: kolla_docker:
action: "pull_image" action: "pull_image"
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
image: "{{ heat_api_image_full }}" image: "{{ item.value.image }}"
when: inventory_hostname in groups['heat-api'] when:
- inventory_hostname in groups[item.value.group]
- name: Pulling heat-api-cfn image - item.value.enabled | bool
kolla_docker: with_dict: "{{ heat_services }}"
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ heat_api_cfn_image_full }}"
when: inventory_hostname in groups['heat-api-cfn']
- name: Pulling heat-engine image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ heat_engine_image_full }}"
when: inventory_hostname in groups['heat-engine']
--- ---
- 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: heat_api, group: heat-api }
- { name: heat_api_cfn, group: heat-api-cfn }
- { name: heat_engine, group: heat-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: heat_api, group: heat-api }
- { name: heat_api_cfn, group: heat-api-cfn }
- { name: heat_engine, group: heat-engine }
# 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: heat_api, group: heat-api }
- { name: heat_api_cfn, group: heat-api-cfn }
- { name: heat_engine, group: heat-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: heat_api, group: heat-api },
{ name: heat_api_cfn, group: heat-api-cfn },
{ name: heat_engine, group: heat-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: heat_api, group: heat-api },
{ name: heat_api_cfn, group: heat-api-cfn },
{ name: heat_engine, group: heat-engine }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
---
- name: Starting heat-api container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ heat_api_image_full }}"
name: "heat_api"
volumes:
- "{{ node_config_directory }}/heat-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['heat-api']
- name: Starting heat-api-cfn container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ heat_api_cfn_image_full }}"
name: "heat_api_cfn"
volumes:
- "{{ node_config_directory }}/heat-api-cfn/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['heat-api-cfn']
- name: Starting heat-engine container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ heat_engine_image_full }}"
name: "heat_engine"
volumes:
- "{{ node_config_directory }}/heat-engine/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['heat-engine']
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
- include: bootstrap_service.yml - include: bootstrap_service.yml
- include: start.yml - name: Flush handlers
meta: flush_handlers
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment