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

Merge "Optimize reconfiguration for octavia"

parents 700089f5 517491a9
No related branches found
No related tags found
No related merge requests found
---
project_name: "octavia"
octavia_services:
octavia-api:
container_name: octavia_api
group: octavia-api
enabled: true
image: "{{ octavia_api_image_full }}"
volumes:
- "{{ node_config_directory }}/octavia-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
octavia-health-manager:
container_name: octavia_health_manager
group: octavia-health-manager
enabled: true
image: "{{ octavia_health_manager_image_full }}"
volumes:
- "{{ node_config_directory }}/octavia-health-manager/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
octavia-housekeeping:
container_name: octavia_housekeeping
group: octavia-housekeeping
enabled: true
image: "{{ octavia_housekeeping_image_full }}"
volumes:
- "{{ node_config_directory }}/octavia-housekeeping/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
octavia-worker:
container_name: octavia_worker
group: octavia-worker
enabled: true
image: "{{ octavia_worker_image_full }}"
volumes:
- "{{ node_config_directory }}/octavia-worker/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
####################
# Database
####################
......
---
- name: Restart octavia-api container
vars:
service_name: "octavia-api"
service: "{{ octavia_services[service_name] }}"
config_json: "{{ octavia_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_conf: "{{ octavia_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_api_container: "{{ check_octavia_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 octavia_conf.changed | bool
or octavia_api_container.changed | bool
- name: Restart octavia-health-manager container
vars:
service_name: "octavia-health-manager"
service: "{{ octavia_services[service_name] }}"
config_json: "{{ octavia_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_conf: "{{ octavia_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_health_manager_container: "{{ check_octavia_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 octavia_conf.changed | bool
or octavia_health_manager_container.changed | bool
- name: Restart octavia-housekeeping container
vars:
service_name: "octavia-housekeeping"
service: "{{ octavia_services[service_name] }}"
config_json: "{{ octavia_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_conf: "{{ octavia_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_housekeeping_container: "{{ check_octavia_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 octavia_conf.changed | bool
or octavia_housekeeping_container.changed | bool
- name: Restart octavia-worker container
vars:
service_name: "octavia-worker"
service: "{{ octavia_services[service_name] }}"
config_json: "{{ octavia_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_conf: "{{ octavia_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_worker_container: "{{ check_octavia_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 octavia_conf.changed | bool
or octavia_worker_certificate.changed | bool
or octavia_worker_container.changed | bool
---
- name: Running Octavia bootstrap container
vars:
octavia_api: "{{ octavia_services['octavia-api'] }}"
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
......@@ -7,14 +9,11 @@
environment:
KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
image: "{{ octavia_api_image_full }}"
image: "{{ octavia_api.image }}"
labels:
BOOTSTRAP:
name: "bootstrap_octavia"
restart_policy: "never"
volumes:
- "{{ node_config_directory }}/octavia-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
volumes: "{{ octavia_api.volumes }}"
run_once: True
delegate_to: "{{ groups['octavia-api'][0] }}"
delegate_to: "{{ groups[octavia_api.group][0] }}"
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
recurse: yes
with_items:
- "octavia-api"
- "octavia-health-manager"
- "octavia-housekeeping"
- "octavia-worker"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ octavia_services }}"
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
with_items:
- "octavia-api"
- "octavia-health-manager"
- "octavia-housekeeping"
- "octavia-worker"
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
register: octavia_config_jsons
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ octavia_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Copying over octavia.conf
merge_configs:
vars:
service_name: "{{ item }}"
service_name: "{{ item.key }}"
sources:
- "{{ role_path }}/templates/octavia.conf.j2"
- "{{ node_config_directory }}/config/global.conf"
- "{{ node_config_directory }}/config/database.conf"
- "{{ node_config_directory }}/config/messaging.conf"
- "{{ node_config_directory }}/config/octavia.conf"
- "{{ node_config_directory }}/config/octavia/{{ item }}.conf"
- "{{ node_config_directory }}/config/octavia/{{ item.key }}.conf"
- "{{ node_config_directory }}/config/octavia/{{ inventory_hostname }}/octavia.conf"
dest: "{{ node_config_directory }}/{{ item }}/octavia.conf"
with_items:
- "octavia-api"
- "octavia-health-manager"
- "octavia-housekeeping"
- "octavia-worker"
dest: "{{ node_config_directory }}/{{ item.key }}/octavia.conf"
register: octavia_confs
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ octavia_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Copying certificate files
vars:
service: "{{ octavia_services['octavia-worker'] }}"
copy:
src: "{{ node_config_directory }}/config/octavia/{{ item }}"
dest: "{{ node_config_directory }}/octavia-worker/{{ item }}"
register: octavia_worker_certificate
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
with_items:
- cakey.pem
- ca_01.pem
- client.pem
notify:
- Restart octavia-worker container
- name: Check octavia 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_octavia_containers
when:
- action != "config"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ octavia_services }}"
notify:
- "Restart {{ item.key }} container"
......@@ -11,8 +11,5 @@
- include: "bootstrap.yml"
when: inventory_hostname in groups['octavia-api']
- include: "start.yml"
when: inventory_hostname in groups['octavia-api'] or
inventory_hostname in groups['octavia-health-manager'] or
inventory_hostname in groups['octavia-housekeeping'] or
inventory_hostname in groups['octavia-worker']
- name: Flush handlers
meta: flush_handlers
---
- name: Pulling octavia-api image
- name: Pulling octavia images
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_api_image_full }}"
when: inventory_hostname in groups['octavia-api']
- name: Pulling octavia-health-manager image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_health_manager_image_full }}"
when: inventory_hostname in groups['octavia-health-manager']
- name: Pulling octavia-housekeeping image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_housekeeping_image_full }}"
when: inventory_hostname in groups['octavia-housekeeping']
- name: Pulling octavia-worker image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_worker_image_full }}"
when: inventory_hostname in groups['octavia-worker']
image: "{{ item.value.image }}"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ octavia_services }}"
---
- 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: octavia_api, group: octavia-api }
- { name: octavia_health_manager, group: octavia-health-manager }
- { name: octavia_housekeeping, group: octavia-housekeeping }
- { name: octavia_worker, group: octavia-worker }
- 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: octavia_api, group: octavia-api }
- { name: octavia_health_manager, group: octavia-health-manager }
- { name: octavia_housekeeping, group: octavia-housekeeping }
- { name: octavia_worker, group: octavia-worker }
- 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: octavia_api, group: octavia-api }
- { name: octavia_health_manager, group: octavia-health-manager }
- { name: octavia_housekeeping, group: octavia-housekeeping }
- { name: octavia_worker, group: octavia-worker }
- 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: octavia_api, group: octavia-api },
{ name: octavia_health_manager, group: octavia-health-manager },
{ name: octavia_housekeeping, group: octavia-housekeeping },
{ name: octavia_worker, group: octavia-worker }]
- "{{ 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: octavia_api, group: octavia-api },
{ name: octavia_health_manager, group: octavia-health-manager },
{ name: octavia_housekeeping, group: octavia-housekeeping },
{ name: octavia_worker, group: octavia-worker }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
- include: deploy.yml
---
- name: Starting octavia-api container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_api_image_full }}"
name: "octavia_api"
volumes:
- "{{ node_config_directory }}/octavia-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['octavia-api']
- name: Starting octavia-health-manager container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_health_manager_image_full }}"
name: "octavia_health_manager"
volumes:
- "{{ node_config_directory }}/octavia-health-manager/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['octavia-health-manager']
- name: Starting octavia-housekeeping container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_housekeeping_image_full }}"
name: "octavia_housekeeping"
volumes:
- "{{ node_config_directory }}/octavia-housekeeping/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['octavia-housekeeping']
- name: Starting octavia-worker container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_worker_image_full }}"
name: "octavia_worker"
volumes:
- "{{ node_config_directory }}/octavia-worker/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['octavia-worker']
......@@ -3,4 +3,5 @@
- 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