Optimize reconfiguration for designate

Co-Authored-By: caoyuan <cao.yuan@99cloud.net>
Co-Authored-By: Francisco Edigleison Barbosa <barbosaedigleison@gmail.com>
Change-Id: I68c7e753060af2544acdb7d0a2c641c85bad42c6
Partially-implements: blueprint better-reconfigure
This commit is contained in:
Mauricio Lima 2017-01-23 11:36:08 -03:00 committed by caoyuan
parent 96185846c3
commit 871733c956
9 changed files with 311 additions and 267 deletions

View File

@ -1,6 +1,64 @@
---
project_name: "designate"
designate_services:
designate-api:
container_name: designate_api
group: designate-api
enabled: true
image: "{{ designate_api_image_full }}"
volumes:
- "{{ node_config_directory }}/designate-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
designate-backend-bind9:
container_name: designate_backend_bind9
group: designate-backend-bind9
enabled: "{{ designate_backend == 'bind9' }}"
image: "{{ designate_backend_bind9_image_full }}"
volumes:
- "{{ node_config_directory }}/designate-backend-bind9/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
- "designate_backend_bind9:/var/lib/named/"
designate-central:
container_name: designate_central
group: designate-central
enabled: true
image: "{{ designate_central_image_full }}"
volumes:
- "{{ node_config_directory }}/designate-central/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
designate-mdns:
container_name: designate_mdns
group: designate-mdns
enabled: true
image: "{{ designate_mdns_image_full }}"
volumes:
- "{{ node_config_directory }}/designate-mdns/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
designate-worker:
container_name: designate_worker
group: designate-worker
enabled: true
image: "{{ designate_worker_image_full }}"
volumes:
- "{{ node_config_directory }}/designate-worker/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
designate-sink:
container_name: designate_sink
group: designate-sink
enabled: true
image: "{{ designate_sink_image_full }}"
volumes:
- "{{ node_config_directory }}/designate-sink/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
####################
# Database
####################

View File

@ -0,0 +1,139 @@
---
- name: Restart designate-api container
vars:
service_name: "designate-api"
service: "{{ designate_services[service_name] }}"
config_json: "{{ designate_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_conf: "{{ designate_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ designate_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_api_container: "{{ check_designate_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 designate_conf.changed | bool
or policy_json.changed | bool
or designate_api_container.changed | bool
- name: Restart designate-backend-bind9 container
vars:
service_name: "designate-backend-bind9"
service: "{{ designate_services[service_name] }}"
config_json: "{{ designate_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_backend_bind9: "{{ check_designate_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 designate_rndc_conf.changed | bool
or designate_rndc_key.changed | bool
or designate_named.changed | bool
or designate_backend_bind9_container.changed | bool
- name: Restart designate-central container
vars:
service_name: "designate-central"
service: "{{ designate_services[service_name] }}"
config_json: "{{ designate_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_conf: "{{ designate_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ designate_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_central_container: "{{ check_designate_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 designate_conf.changed | bool
or policy_json.changed | bool
or designate_central_container.changed | bool
- name: Restart designate-mdns container
vars:
service_name: "designate-mdns"
service: "{{ designate_services[service_name] }}"
config_json: "{{ designate_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_conf: "{{ designate_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ designate_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_mdns_container: "{{ check_designate_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 designate_conf.changed | bool
or policy_json.changed | bool
or designate_mdns_container.changed | bool
- name: Restart designate-worker container
vars:
service_name: "designate-worker"
service: "{{ designate_services[service_name] }}"
config_json: "{{ designate_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_conf: "{{ designate_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ designate_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_worker_container: "{{ check_designate_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 designate_conf.changed | bool
or designate_rndc_conf.changed | bool
or designate_rndc_key.changed | bool
or policy_json.changed | bool
or designate_worker_container.changed | bool
- name: Restart designate-sink container
vars:
service_name: "designate-sink"
service: "{{ designate_services[service_name] }}"
config_json: "{{ designate_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_conf: "{{ designate_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ designate_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
designate_sink_container: "{{ check_designate_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 designate_conf.changed | bool
or policy_json.changed | bool
or designate_sink_container.changed | bool

View File

@ -1,5 +1,7 @@
---
- name: Running Designate bootstrap container
vars:
designate_central: "{{ designate_services['designate-central'] }}"
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
@ -7,14 +9,11 @@
environment:
KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
image: "{{ designate_central_image_full }}"
image: "{{ designate_central.image }}"
labels:
BOOTSTRAP:
name: "bootstrap_designate"
restart_policy: "never"
volumes:
- "{{ node_config_directory }}/designate-central/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
volumes: "{{ designate_central.volumes }}"
run_once: True
delegate_to: "{{ groups['designate-central'][0] }}"
delegate_to: "{{ groups[designate_central.group][0] }}"

View File

@ -1,93 +1,120 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
recurse: yes
with_items:
- "designate-api"
- "designate-central"
- "designate-mdns"
- "designate-sink"
- "designate-backend-bind9"
- "designate-worker"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ designate_services }}"
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
with_items:
- "designate-api"
- "designate-central"
- "designate-mdns"
- "designate-sink"
- "designate-backend-bind9"
- "designate-worker"
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
register: designate_config_jsons
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ designate_services }}"
notify:
- Restart designate-api container
- Restart designate-central container
- Restart designate-mdns container
- Restart designate-sink container
- Restart designate-backend-bind9 container
- Restart designate-worker container
- name: Copying over designate.conf
merge_configs:
vars:
service_name: "{{ item }}"
service_name: "{{ item.key }}"
sources:
- "{{ role_path }}/templates/designate.conf.j2"
- "{{ node_custom_config }}/global.conf"
- "{{ node_custom_config }}/database.conf"
- "{{ node_custom_config }}/messaging.conf"
- "{{ node_custom_config }}/designate.conf"
- "{{ node_custom_config }}/designate/{{ item }}.conf"
- "{{ node_custom_config }}/designate/{{ item.key }}.conf"
- "{{ node_custom_config }}/designate/{{ inventory_hostname }}/designate.conf"
dest: "{{ node_config_directory }}/{{ item }}/designate.conf"
with_items:
- "designate-api"
- "designate-central"
- "designate-mdns"
- "designate-sink"
- "designate-worker"
dest: "{{ node_config_directory }}/{{ item.key }}/designate.conf"
register: designate_confs
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ designate_services }}"
notify:
- Restart designate-api container
- Restart designate-central container
- Restart designate-mdns container
- Restart designate-sink container
- Restart designate-worker container
- name: Copying over pools.yaml
vars:
service: "{{ designate_services['designate-worker'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/designate-worker/pools.yaml"
register: designate_pool
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
with_first_found:
- "{{ node_custom_config }}/designate/pools.yaml"
- "{{ role_path }}/templates/pools.yaml.j2"
notify:
- Restart designate-worker container
- name: Copying over named.conf
vars:
service: "{{ designate_services['designate-backend-bind9'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/designate-backend-bind9/named.conf"
register: designate_named
when:
- designate_backend == 'bind9'
- inventory_hostname in groups[service.group]
- service.enabled | bool
with_first_found:
- "{{ node_custom_config }}/designate/designate-backend-bind9/{{ inventory_hostname }}/named.conf"
- "{{ node_custom_config }}/designate/designate-backend-bind9/named.conf"
- "{{ node_custom_config }}/designate/named.conf"
- "{{ role_path }}/templates/named.conf.j2"
when:
- designate_backend == 'bind9'
- inventory_hostname in groups['designate-backend-bind9']
notify:
- Restart designate-backend-bind9 container
- name: Copying over rndc.conf
template:
src: "rndc.conf.j2"
dest: "{{ node_config_directory }}/{{ item }}/rndc.conf"
with_items:
- "designate-backend-bind9"
- "designate-worker"
register: designate_rndc_conf
when:
- designate_backend == 'bind9'
- inventory_hostname in groups['designate-backend-bind9']
or inventory_hostname in groups['designate-worker']
- item.key in [ "designate-backend-bind9", "designate-worker" ]
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ designate_services }}"
notify:
- Restart designate-backend-bind9 container
- Restart designate-worker container
- name: Copying over rndc.key
template:
src: "rndc.key.j2"
dest: "{{ node_config_directory }}/{{ item }}/rndc.key"
with_items:
- "designate-backend-bind9"
- "designate-worker"
register: designate_rndc_key
when:
- designate_backend == 'bind9'
- inventory_hostname in groups['designate-backend-bind9']
or inventory_hostname in groups['designate-worker']
- item.key in [ "designate-backend-bind9", "designate-worker" ]
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ designate_services }}"
notify:
- Restart designate-backend-bind9 container
- Restart designate-worker container
- name: Check if policies shall be overwritten
local_action: stat path="{{ node_custom_config }}/designate/policy.json"
@ -96,12 +123,37 @@
- name: Copying over existing policy.json
template:
src: "{{ node_custom_config }}/designate/policy.json"
dest: "{{ node_config_directory }}/{{ item }}/policy.json"
with_items:
- "designate-api"
- "designate-central"
- "designate-mdns"
- "designate-sink"
- "designate-worker"
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
register: designate_policy_jsons
when:
designate_policy.stat.exists
- designate_policy.stat.exists
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ designate_services }}"
notify:
- Restart designate-api container
- Restart designate-central container
- Restart designate-mdns container
- Restart designate-sink container
- Restart designate-worker container
- name: Check designate 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_designate_containers
when:
- action != "config"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ designate_services }}"
notify:
- Restart designate-api container
- Restart designate-central container
- Restart designate-mdns container
- Restart designate-sink container
- Restart designate-backend-bind9 container
- Restart designate-worker container

View File

@ -13,13 +13,8 @@
- include: bootstrap.yml
when: inventory_hostname in groups['designate-central']
- include: start.yml
when: inventory_hostname in groups['designate-api'] or
inventory_hostname in groups['designate-central'] or
inventory_hostname in groups['designate-mdns'] or
inventory_hostname in groups['designate-worker'] or
inventory_hostname in groups['designate-sink'] or
inventory_hostname in groups['designate-backend-bind9']
- name: Flush handlers
meta: flush_handlers
- include: update_pools.yml
when: inventory_hostname in groups['designate-worker'][0]

View File

@ -1,44 +1,10 @@
---
- name: Pulling designate-api image
- name: Pulling designate images
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ designate_api_image_full }}"
when: inventory_hostname in groups['designate-api']
- name: Pulling designate-central image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ designate_central_image_full }}"
when: inventory_hostname in groups['designate-central']
- name: Pulling designate-mdns image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ designate_mdns_image_full }}"
when: inventory_hostname in groups['designate-mdns']
- name: Pulling designate-worker image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ designate_worker_image_full }}"
when: inventory_hostname in groups['designate-worker']
- name: Pulling designate-sink image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ designate_sink_image_full }}"
when: inventory_hostname in groups['designate-sink']
- name: Pulling designate-backend-bind9 image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ designate_backend_bind9_image_full }}"
image: "{{ item.value.image }}"
when:
- designate_backend == 'bind9'
- inventory_hostname in groups['designate-backend-bind9']
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ designate_services }}"

View File

@ -1,93 +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:
- "{{ item.enabled|default(True) }}"
- inventory_hostname in groups[item.group]
with_items:
- { name: designate_central, group: designate-central }
- { name: designate_api, group: designate-api }
- { name: designate_mdns, group: designate-mdns }
- { name: designate_worker, group: designate-worker }
- { name: designate_sink, group: designate-sink }
- { name: designate_backend_bind9, group: designate-backend-bind9 }
- 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: designate_central, group: designate-central }
- { name: designate_api, group: designate-api }
- { name: designate_mdns, group: designate-mdns }
- { name: designate_worker, group: designate-worker }
- { name: designate_sink, group: designate-sink }
- { name: designate_backend_bind9, group: designate-backend-bind9 }
# 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: designate_central, group: designate-central }
- { name: designate_api, group: designate-api }
- { name: designate_mdns, group: designate-mdns }
- { name: designate_worker, group: designate-worker }
- { name: designate_sink, group: designate-sink }
- { name: designate_backend_bind9, group: designate-backend-bind9 }
- 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: designate_central, group: designate-central },
{ name: designate_api, group: designate-api },
{ name: designate_mdns, group: designate-mdns },
{ name: designate_worker, group: designate-worker },
{ name: designate_sink, group: designate-sink },
{ name: designate_backend_bind9, group: designate-backend-bind9 }]
- "{{ 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: designate_central, group: designate-central },
{ name: designate_api, group: designate-api },
{ name: designate_mdns, group: designate-mdns },
{ name: designate_worker, group: designate-worker },
{ name: designate_sink, group: designate-sink },
{ name: designate_backend_bind9, group: designate-backend-bind9 }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
- include: update_pools.yml
- include: deploy.yml

View File

@ -1,75 +0,0 @@
---
- name: Starting designate-backend-bind9 container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ designate_backend_bind9_image_full }}"
name: "designate_backend_bind9"
volumes:
- "{{ node_config_directory }}/designate-backend-bind9/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
- "designate_backend_bind9:/var/lib/named/"
when:
- designate_backend == 'bind9'
- inventory_hostname in groups['designate-backend-bind9']
- name: Starting designate-central container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ designate_central_image_full }}"
name: "designate_central"
volumes:
- "{{ node_config_directory }}/designate-central/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['designate-central']
- name: Starting designate-api container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ designate_api_image_full }}"
name: "designate_api"
volumes:
- "{{ node_config_directory }}/designate-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['designate-api']
- name: Starting designate-mdns container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ designate_mdns_image_full }}"
name: "designate_mdns"
volumes:
- "{{ node_config_directory }}/designate-mdns/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['designate-mdns']
- name: Starting designate-worker container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ designate_worker_image_full }}"
name: "designate_worker"
volumes:
- "{{ node_config_directory }}/designate-worker/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['designate-worker']
- name: Starting designate-sink container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ designate_sink_image_full }}"
name: "designate_sink"
volumes:
- "{{ node_config_directory }}/designate-sink/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['designate-sink']

View File

@ -3,6 +3,7 @@
- include: bootstrap_service.yml
- include: start.yml
- name: Flush handlers
meta: flush_handlers
- include: update_pools.yml