Optimize reconfiguration for ceilometer

Change-Id: I9667e087f3dede751ce80734511e53761f5e9298
Partially-implements: blueprint better-reconfigure
This commit is contained in:
caoyuan 2017-01-21 17:22:24 +08:00
parent 7f3d7a30d9
commit 7ec120aec3
9 changed files with 271 additions and 225 deletions

View File

@ -1,6 +1,60 @@
---
project_name: "ceilometer"
ceilometer_services:
ceilometer-api:
container_name: ceilometer_api
group: ceilometer-api
enabled: True
image: "{{ ceilometer_api_image_full }}"
volumes:
- "{{ node_config_directory }}/ceilometer-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "ceilometer:/var/lib/ceilometer/"
- "kolla_logs:/var/log/kolla/"
ceilometer-notification:
container_name: ceilometer_notification
group: ceilometer-notification
enabled: True
image: "{{ ceilometer_notification_image_full }}"
volumes:
- "{{ node_config_directory }}/ceilometer-notification/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
ceilometer-central:
container_name: ceilometer_central
group: ceilometer-central
enabled: True
image: "{{ ceilometer_central_image_full }}"
volumes:
- "{{ node_config_directory }}/ceilometer-central/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "ceilometer:/var/lib/ceilometer/"
- "kolla_logs:/var/log/kolla/"
ceilometer-collector:
container_name: ceilometer_collector
group: ceilometer-collector
enabled: True
image: "{{ ceilometer_collector_image_full }}"
volumes:
- "{{ node_config_directory }}/ceilometer-collector/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "ceilometer:/var/lib/ceilometer/"
- "kolla_logs:/var/log/kolla/"
ceilometer-compute:
container_name: ceilometer_compute
group: ceilometer-compute
enabled: True
privileged: True
image: "{{ ceilometer_compute_image_full }}"
volumes:
- "{{ node_config_directory }}/ceilometer-compute/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "/run/:/run/:shared"
- "ceilometer:/var/lib/ceilometer/"
- "kolla_logs:/var/log/kolla/"
- "nova_libvirt:/var/lib/libvirt"
####################
# Database

View File

@ -0,0 +1,118 @@
---
- name: Restart ceilometer-api container
vars:
service_name: "ceilometer-api"
service: "{{ ceilometer_services[service_name] }}"
config_json: "{{ ceilometer_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_conf: "{{ ceilometer_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ ceilometer_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_api_container: "{{ check_ceilometer_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 ceilometer_conf.changed | bool
or policy_json.changed | bool
or wsgi_ceilometer_api.changed | bool
or ceilometer_api_container.changed | bool
- name: Restart ceilometer-notification container
vars:
service_name: "ceilometer-notification"
service: "{{ ceilometer_services[service_name] }}"
config_json: "{{ ceilometer_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_conf: "{{ ceilometer_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ ceilometer_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_notification_container: "{{ check_ceilometer_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 ceilometer_conf.changed | bool
or policy_json.changed | bool
or ceilometer_events.changed | bool
or ceilometer_notification_container.changed | bool
- name: Restart ceilometer-central container
vars:
service_name: "ceilometer-central"
service: "{{ ceilometer_services[service_name] }}"
config_json: "{{ ceilometer_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_conf: "{{ ceilometer_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ ceilometer_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_central_container: "{{ check_ceilometer_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 ceilometer_conf.changed | bool
or policy_json.changed | bool
or ceilometer_central_container.changed | bool
- name: Restart ceilometer-collector container
vars:
service_name: "ceilometer-collector"
service: "{{ ceilometer_services[service_name] }}"
config_json: "{{ ceilometer_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_conf: "{{ ceilometer_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ ceilometer_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_collector_container: "{{ check_ceilometer_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 ceilometer_conf.changed | bool
or policy_json.changed | bool
or ceilometer_collector_container.changed | bool
- name: Restart ceilometer-compute container
vars:
service_name: "ceilometer-compute"
service: "{{ ceilometer_services[service_name] }}"
config_json: "{{ ceilometer_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_conf: "{{ ceilometer_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ ceilometer_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_compute_container: "{{ check_ceilometer_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 ceilometer_conf.changed | bool
or policy_json.changed | bool
or ceilometer_compute_container.changed | bool

View File

@ -1,5 +1,7 @@
---
- name: Running Ceilometer bootstrap container
vars:
ceilometer_api: "{{ ceilometer_services['ceilometer-api'] }}"
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
@ -8,15 +10,11 @@
KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
CEILOMETER_DATABASE_TYPE: "{{ ceilometer_database_type }}"
image: "{{ ceilometer_api_image_full }}"
image: "{{ ceilometer_api.image }}"
labels:
BOOTSTRAP:
name: "bootstrap_ceilometer"
restart_policy: "never"
volumes:
- "{{ node_config_directory }}/ceilometer-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "ceilometer:/var/lib/ceilometer/"
- "kolla_logs:/var/log/kolla/"
volumes: "{{ ceilometer_api.volumes }}"
run_once: True
delegate_to: "{{ groups['ceilometer-api'][0] }}"
delegate_to: "{{ groups[ceilometer_api.group][0] }}"

View File

@ -1,28 +1,33 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
recurse: yes
with_items:
- "ceilometer-notification"
- "ceilometer-collector"
- "ceilometer-api"
- "ceilometer-central"
- "ceilometer-compute"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ceilometer_services }}"
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
with_items:
- "ceilometer-notification"
- "ceilometer-collector"
- "ceilometer-api"
- "ceilometer-central"
- "ceilometer-compute"
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
register: ceilometer_config_jsons
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ceilometer_services }}"
notify:
- Restart ceilometer-api container
- Restart ceilometer-notification container
- Restart ceilometer-central container
- Restart ceilometer-collector container
- Restart ceilometer-compute container
- name: Copying over ceilometer-api.conf
- name: Copying over wsgi-ceilometer-api.conf
vars:
service: "{{ ceilometer_services['ceilometer-api'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/ceilometer-api/wsgi-ceilometer-api.conf"
@ -30,35 +35,54 @@
- "{{ node_custom_config }}/ceilometer/{{ inventory_hostname }}/wsgi-ceilometer-api.conf"
- "{{ node_custom_config }}/ceilometer/wsgi-ceilometer-api.conf"
- "wsgi-ceilometer-api.conf.j2"
register: wsgi_ceilometer_api
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
notify:
- Restart ceilometer-api container
- name: Copying over ceilometer.conf
merge_configs:
vars:
service_name: "{{ item }}"
service_name: "{{ item.key }}"
sources:
- "{{ role_path }}/templates/ceilometer.conf.j2"
- "{{ node_custom_config }}/global.conf"
- "{{ node_custom_config }}/database.conf"
- "{{ node_custom_config }}/messaging.conf"
- "{{ node_custom_config }}/ceilometer.conf"
- "{{ node_custom_config }}/ceilometer/{{ item }}.conf"
- "{{ node_custom_config }}/ceilometer/{{ item.key }}.conf"
- "{{ node_custom_config }}/ceilometer/{{ inventory_hostname }}/ceilometer.conf"
dest: "{{ node_config_directory }}/{{ item }}/ceilometer.conf"
with_items:
- "ceilometer-notification"
- "ceilometer-collector"
- "ceilometer-api"
- "ceilometer-central"
- "ceilometer-compute"
dest: "{{ node_config_directory }}/{{ item.key }}/ceilometer.conf"
register: ceilometer_confs
when:
- item.value.enabled | bool
- inventory_hostname in groups[item.value.group]
with_dict: "{{ ceilometer_services }}"
notify:
- Restart ceilometer-api container
- Restart ceilometer-notification container
- Restart ceilometer-central container
- Restart ceilometer-collector container
- Restart ceilometer-compute container
- name: Copying over event and pipeline yaml for notification service
vars:
service: "{{ ceilometer_services['ceilometer-notification'] }}"
template:
src: "{{ item }}.j2"
dest: "{{ node_config_directory }}/ceilometer-notification/{{ item }}"
register: ceilometer_events
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
with_items:
- "event_definitions.yaml"
- "event_pipeline.yaml"
- "pipeline.yaml"
notify:
- Restart ceilometer-notification container
- name: Check if policies shall be overwritten
local_action: stat path="{{ node_custom_config }}/ceilometer/policy.json"
@ -67,12 +91,38 @@
- name: Copying over existing policy.json
template:
src: "{{ node_custom_config }}/ceilometer/policy.json"
dest: "{{ node_config_directory }}/{{ item }}/policy.json"
with_items:
- "ceilometer-notification"
- "ceilometer-collector"
- "ceilometer-api"
- "ceilometer-central"
- "ceilometer-compute"
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
register: ceilometer_policy_jsons
when:
ceilometer_policy.stat.exists
- ceilometer_policy.stat.exists
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ceilometer_services }}"
notify:
- Restart ceilometer-api container
- Restart ceilometer-notification container
- Restart ceilometer-central container
- Restart ceilometer-collector container
- Restart ceilometer-compute container
# check whether the containers parameter is changed. If yes, trigger the handler.
- name: Check ceilometer containers
kolla_docker:
action: "compare_container"
common_options: "{{ docker_common_options }}"
name: "{{ item.value.container_name }}"
image: "{{ item.value.image }}"
privileged: "{{ item.value.privileged | default(False) }}"
volumes: "{{ item.value.volumes }}"
register: check_ceilometer_containers
when:
- action != "config"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ceilometer_services }}"
notify:
- Restart ceilometer-api container
- Restart ceilometer-notification container
- Restart ceilometer-central container
- Restart ceilometer-collector container
- Restart ceilometer-compute container

View File

@ -9,6 +9,5 @@
- include: bootstrap.yml
when: inventory_hostname in groups['ceilometer']
- include: start.yml
when: inventory_hostname in groups['ceilometer'] or
inventory_hostname in groups['compute']
- name: Flush handlers
meta: flush_handlers

View File

@ -1,35 +1,10 @@
---
- name: Pulling ceilometer-notification image
- name: Pulling ceilometer images
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_notification_image_full }}"
when: inventory_hostname in groups['ceilometer-notification']
- name: Pulling ceilometer-api image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_api_image_full }}"
when: inventory_hostname in groups['ceilometer-api']
- name: Pulling ceilometer-central image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_central_image_full }}"
when: inventory_hostname in groups['ceilometer-central']
- name: Pulling ceilometer-collector image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_collector_image_full }}"
when: inventory_hostname in groups['ceilometer-collector']
- name: Pulling ceilometer-compute image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_compute_image_full }}"
when: inventory_hostname in groups['ceilometer-compute']
image: "{{ item.value.image }}"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ceilometer_services }}"

View File

@ -1,84 +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: ceilometer_api, group: ceilometer-api }
- { name: ceilometer_central, group: ceilometer-central }
- { name: ceilometer_notification, group: ceilometer-notification }
- { name: ceilometer_collector, group: ceilometer-collector }
- { name: ceilometer_compute, group: ceilometer-compute }
- 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: ceilometer_api, group: ceilometer-api }
- { name: ceilometer_central, group: ceilometer-central }
- { name: ceilometer_notification, group: ceilometer-notification }
- { name: ceilometer_collector, group: ceilometer-collector }
- { name: ceilometer_compute, group: ceilometer-compute }
# 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: ceilometer_api, group: ceilometer-api }
- { name: ceilometer_central, group: ceilometer-central }
- { name: ceilometer_notification, group: ceilometer-notification }
- { name: ceilometer_collector, group: ceilometer-collector }
- { name: ceilometer_compute, group: ceilometer-compute }
- 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: ceilometer_api, group: ceilometer-api },
{ name: ceilometer_central, group: ceilometer-central },
{ name: ceilometer_notification, group: ceilometer-notification },
{ name: ceilometer_collector, group: ceilometer-collector },
{ name: ceilometer_compute, group: ceilometer-compute }]
- "{{ 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: ceilometer_api, group: ceilometer-api },
{ name: ceilometer_central, group: ceilometer-central },
{ name: ceilometer_notification, group: ceilometer-notification },
{ name: ceilometer_collector, group: ceilometer-collector },
{ name: ceilometer_compute, group: ceilometer-compute }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
- include: deploy.yml

View File

@ -1,67 +0,0 @@
---
- name: Starting ceilometer-notification container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_notification_image_full }}"
name: "ceilometer_notification"
volumes:
- "{{ node_config_directory }}/ceilometer-notification/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['ceilometer-notification']
- name: Starting ceilometer-api container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_api_image_full }}"
name: "ceilometer_api"
volumes:
- "{{ node_config_directory }}/ceilometer-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "ceilometer:/var/lib/ceilometer/"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['ceilometer-api']
- name: Starting ceilometer-central container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_central_image_full }}"
name: "ceilometer_central"
volumes:
- "{{ node_config_directory }}/ceilometer-central/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "ceilometer:/var/lib/ceilometer/"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['ceilometer-central']
- name: Starting ceilometer-collector container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_collector_image_full }}"
name: "ceilometer_collector"
volumes:
- "{{ node_config_directory }}/ceilometer-collector/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "ceilometer:/var/lib/ceilometer/"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['ceilometer-collector']
- name: Starting ceilometer-compute container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_compute_image_full }}"
name: "ceilometer_compute"
privileged: True
volumes:
- "{{ node_config_directory }}/ceilometer-compute/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "/run/:/run/:shared"
- "ceilometer:/var/lib/ceilometer/"
- "kolla_logs:/var/log/kolla/"
- "nova_libvirt:/var/lib/libvirt"
when: inventory_hostname in groups['ceilometer-compute']

View File

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