Merge "Optimize reconfigure action for horizon"
This commit is contained in:
commit
5f3456bf39
@ -1,6 +1,35 @@
|
||||
---
|
||||
project_name: "horizon"
|
||||
|
||||
horizon_services:
|
||||
horizon:
|
||||
container_name: horizon
|
||||
group: horizon
|
||||
enabled: true
|
||||
image: "{{ horizon_image_full }}"
|
||||
environment:
|
||||
ENABLE_CLOUDKITTY: "{{ 'yes' if enable_horizon_cloudkitty | bool else 'no' }}"
|
||||
ENABLE_FREEZER: "{{ 'yes' if enable_horizon_freezer | bool else 'no' }}"
|
||||
ENABLE_IRONIC: "{{ 'yes' if enable_horizon_ironic | bool else 'no' }}"
|
||||
ENABLE_KARBOR: "{{ 'yes' if enable_horizon_karbor | bool else 'no' }}"
|
||||
ENABLE_MAGNUM: "{{ 'yes' if enable_horizon_magnum | bool else 'no' }}"
|
||||
ENABLE_MANILA: "{{ 'yes' if enable_horizon_manila | bool else 'no' }}"
|
||||
ENABLE_MISTRAL: "{{ 'yes' if enable_horizon_mistral | bool else 'no' }}"
|
||||
ENABLE_MURANO: "{{ 'yes' if enable_horizon_murano | bool else 'no' }}"
|
||||
ENABLE_NEUTRON_LBAAS: "{{ 'yes' if enable_horizon_neutron_lbaas | bool else 'no' }}"
|
||||
ENABLE_SAHARA: "{{ 'yes' if enable_horizon_sahara | bool else 'no' }}"
|
||||
ENABLE_SEARCHLIGHT: "{{ 'yes' if enable_horizon_searchlight | bool else 'no' }}"
|
||||
ENABLE_SENLIN: "{{ 'yes' if enable_horizon_senlin | bool else 'no' }}"
|
||||
ENABLE_SOLUM: "{{ 'yes' if enable_horizon_solum | bool else 'no' }}"
|
||||
ENABLE_TACKER: "{{ 'yes' if enable_horizon_tacker | bool else 'no' }}"
|
||||
ENABLE_TROVE: "{{ 'yes' if enable_horizon_trove | bool else 'no' }}"
|
||||
ENABLE_WATCHER: "{{ 'yes' if enable_horizon_watcher | bool else 'no' }}"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/horizon/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
|
||||
|
||||
####################
|
||||
# Database
|
||||
####################
|
||||
|
21
ansible/roles/horizon/handlers/main.yml
Normal file
21
ansible/roles/horizon/handlers/main.yml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
- name: Restart horizon container
|
||||
vars:
|
||||
service_name: "horizon"
|
||||
service: "{{ horizon_services[service_name] }}"
|
||||
kolla_docker:
|
||||
action: "recreate_or_restart_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "{{ service.container_name }}"
|
||||
image: "{{ service.image }}"
|
||||
environment: "{{ service.environment }}"
|
||||
volumes: "{{ service.volumes }}"
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
- horizon_config_json | changed
|
||||
or horizon_conf | changed
|
||||
or horizon_local_settings | changed
|
||||
or policy_jsons | changed
|
||||
or check_horizon_container | changed
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
- name: Running Horizon bootstrap container
|
||||
vars:
|
||||
horizon: "{{ horizon_services['horizon'] }}"
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
@ -7,13 +9,11 @@
|
||||
environment:
|
||||
KOLLA_BOOTSTRAP:
|
||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||
image: "{{ horizon_image_full }}"
|
||||
image: "{{ horizon.image }}"
|
||||
labels:
|
||||
BOOTSTRAP:
|
||||
name: "bootstrap_horizon"
|
||||
restart_policy: "never"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/horizon/:{{ container_config_directory }}/:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
volumes: "{{ horizon.volumes }}"
|
||||
run_once: True
|
||||
delegate_to: "{{ groups['horizon'][0] }}"
|
||||
delegate_to: "{{ groups[horizon.group][0] }}"
|
||||
|
@ -1,29 +1,45 @@
|
||||
---
|
||||
- name: Ensuring config directories exist
|
||||
file:
|
||||
path: "{{ node_config_directory }}/{{ item }}"
|
||||
path: "{{ node_config_directory }}/{{ item.key }}"
|
||||
state: "directory"
|
||||
recurse: yes
|
||||
with_items:
|
||||
- "horizon"
|
||||
when: inventory_hostname in groups[item.value.group]
|
||||
with_dict: "{{ horizon_services }}"
|
||||
|
||||
- name: Copying over config.json files for services
|
||||
vars:
|
||||
horizon: "{{ horizon_services['horizon'] }}"
|
||||
template:
|
||||
src: "{{ item }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/config.json"
|
||||
with_items:
|
||||
- "horizon"
|
||||
src: "horizon.json.j2"
|
||||
dest: "{{ node_config_directory }}/horizon/config.json"
|
||||
register: horizon_config_json
|
||||
when:
|
||||
- horizon.enabled | bool
|
||||
- inventory_hostname in groups[horizon.group]
|
||||
notify:
|
||||
- Restart horizon container
|
||||
|
||||
- name: Copying over horizon.conf
|
||||
vars:
|
||||
horizon: "{{ horizon_services['horizon'] }}"
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ node_config_directory }}/horizon/horizon.conf"
|
||||
register: horizon_conf
|
||||
with_first_found:
|
||||
- "{{ node_custom_config }}/horizon/{{ inventory_hostname }}/horizon.conf"
|
||||
- "{{ node_custom_config }}/horizon/horizon.conf"
|
||||
- "horizon.conf.j2"
|
||||
when:
|
||||
- horizon.enabled | bool
|
||||
- inventory_hostname in groups[horizon.group]
|
||||
notify:
|
||||
- Restart horizon container
|
||||
|
||||
- name: Copying over local_settings
|
||||
vars:
|
||||
horizon: "{{ horizon_services['horizon'] }}"
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ node_config_directory }}/horizon/local_settings"
|
||||
@ -31,6 +47,12 @@
|
||||
- "{{ node_custom_config }}/horizon/{{ inventory_hostname }}/local_settings"
|
||||
- "{{ node_custom_config }}/horizon/local_settings"
|
||||
- "local_settings.j2"
|
||||
register: horizon_local_settings
|
||||
when:
|
||||
- horizon.enabled | bool
|
||||
- inventory_hostname in groups[horizon.group]
|
||||
notify:
|
||||
- Restart horizon container
|
||||
|
||||
- name: Check if policies shall be overwritten
|
||||
local_action: stat path="{{ node_custom_config }}/horizon/{{ item.name }}_policy.json"
|
||||
@ -52,10 +74,15 @@
|
||||
- { name: "trove", enabled: "{{ enable_trove }}" }
|
||||
|
||||
- name: Copying over existing policy.json
|
||||
vars:
|
||||
horizon: "{{ horizon_services['horizon'] }}"
|
||||
template:
|
||||
src: "{{ node_custom_config }}/horizon/{{ item[0]['name'] }}_policy.json"
|
||||
dest: "{{ node_config_directory }}/horizon/{{ item[0]['name'] }}_policy.json"
|
||||
register: policy_jsons
|
||||
when:
|
||||
- horizon.enabled | bool
|
||||
- inventory_hostname in groups[horizon.group]
|
||||
- item[0]['enabled'] | bool
|
||||
- item[1]['stat']['exists']
|
||||
with_together:
|
||||
@ -73,3 +100,21 @@
|
||||
{ name: "senlin", enabled: "{{ enable_senlin }}" },
|
||||
{ name: "trove", enabled: "{{ enable_trove }}" }]
|
||||
- "{{ custom_policy.results }}"
|
||||
|
||||
- name: Check horizon container
|
||||
vars:
|
||||
horizon: "{{ horizon_services['horizon'] }}"
|
||||
kolla_docker:
|
||||
action: "compare_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "{{ horizon.container_name }}"
|
||||
image: "{{ horizon.image }}"
|
||||
environment: "{{ horizon.environment }}"
|
||||
volumes: "{{ horizon.volumes }}"
|
||||
register: check_horizon_container
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[horizon.group]
|
||||
- horizon.enabled | bool
|
||||
notify:
|
||||
- Restart horizon container
|
||||
|
@ -4,4 +4,5 @@
|
||||
- include: bootstrap.yml
|
||||
when: horizon_backend_database | bool
|
||||
|
||||
- include: start.yml
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
@ -6,6 +6,8 @@
|
||||
register: container_facts
|
||||
|
||||
- name: Checking free port for Horizon
|
||||
vars:
|
||||
horizon: "{{ horizon_services['horizon'] }}"
|
||||
wait_for:
|
||||
host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
|
||||
port: "{{ horizon_port }}"
|
||||
@ -13,4 +15,4 @@
|
||||
state: stopped
|
||||
when:
|
||||
- container_facts['horizon'] is not defined
|
||||
- inventory_hostname in groups['horizon']
|
||||
- inventory_hostname in groups[horizon.group]
|
||||
|
@ -1,7 +1,10 @@
|
||||
---
|
||||
- name: Pulling horizon image
|
||||
- name: Pulling horizon images
|
||||
kolla_docker:
|
||||
action: "pull_image"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ horizon_image_full }}"
|
||||
when: inventory_hostname in groups['horizon']
|
||||
image: "{{ item.value.image }}"
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_items: "{{ horizon_services }}"
|
||||
|
@ -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: horizon, group: horizon }
|
||||
|
||||
- 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: horizon, group: horizon }
|
||||
|
||||
# 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: horizon, group: horizon }
|
||||
|
||||
- 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: horizon, group: horizon }]
|
||||
- "{{ 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: horizon, group: horizon }]
|
||||
- "{{ container_envs.results }}"
|
||||
- "{{ check_results.results }}"
|
||||
- include: "deploy.yml"
|
||||
|
@ -1,29 +0,0 @@
|
||||
---
|
||||
- name: Starting horizon container
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ horizon_image_full }}"
|
||||
name: "horizon"
|
||||
environment:
|
||||
ENABLE_CLOUDKITTY: "{{ 'yes' if enable_horizon_cloudkitty | bool else 'no' }}"
|
||||
ENABLE_FREEZER: "{{ 'yes' if enable_horizon_freezer | bool else 'no' }}"
|
||||
ENABLE_IRONIC: "{{ 'yes' if enable_horizon_ironic | bool else 'no' }}"
|
||||
ENABLE_KARBOR: "{{ 'yes' if enable_horizon_karbor | bool else 'no' }}"
|
||||
ENABLE_MAGNUM: "{{ 'yes' if enable_horizon_magnum | bool else 'no' }}"
|
||||
ENABLE_MANILA: "{{ 'yes' if enable_horizon_manila | bool else 'no' }}"
|
||||
ENABLE_MISTRAL: "{{ 'yes' if enable_horizon_mistral | bool else 'no' }}"
|
||||
ENABLE_MURANO: "{{ 'yes' if enable_horizon_murano | bool else 'no' }}"
|
||||
ENABLE_NEUTRON_LBAAS: "{{ 'yes' if enable_horizon_neutron_lbaas | bool else 'no' }}"
|
||||
ENABLE_SAHARA: "{{ 'yes' if enable_horizon_sahara | bool else 'no' }}"
|
||||
ENABLE_SEARCHLIGHT: "{{ 'yes' if enable_horizon_searchlight | bool else 'no' }}"
|
||||
ENABLE_SENLIN: "{{ 'yes' if enable_horizon_senlin | bool else 'no' }}"
|
||||
ENABLE_SOLUM: "{{ 'yes' if enable_horizon_solum | bool else 'no' }}"
|
||||
ENABLE_TACKER: "{{ 'yes' if enable_horizon_tacker | bool else 'no' }}"
|
||||
ENABLE_TROVE: "{{ 'yes' if enable_horizon_trove | bool else 'no' }}"
|
||||
ENABLE_WATCHER: "{{ 'yes' if enable_horizon_watcher | bool else 'no' }}"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/horizon/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
when: inventory_hostname in groups['horizon']
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
- include: config.yml
|
||||
|
||||
- include: start.yml
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
Loading…
Reference in New Issue
Block a user