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" 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 # 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 - name: Running Ceilometer bootstrap container
vars:
ceilometer_api: "{{ ceilometer_services['ceilometer-api'] }}"
kolla_docker: kolla_docker:
action: "start_container" action: "start_container"
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
@ -8,15 +10,11 @@
KOLLA_BOOTSTRAP: KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
CEILOMETER_DATABASE_TYPE: "{{ ceilometer_database_type }}" CEILOMETER_DATABASE_TYPE: "{{ ceilometer_database_type }}"
image: "{{ ceilometer_api_image_full }}" image: "{{ ceilometer_api.image }}"
labels: labels:
BOOTSTRAP: BOOTSTRAP:
name: "bootstrap_ceilometer" name: "bootstrap_ceilometer"
restart_policy: "never" restart_policy: "never"
volumes: volumes: "{{ 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/"
run_once: True 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 - 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:
- "ceilometer-notification" - inventory_hostname in groups[item.value.group]
- "ceilometer-collector" - item.value.enabled | bool
- "ceilometer-api" with_dict: "{{ ceilometer_services }}"
- "ceilometer-central"
- "ceilometer-compute"
- 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: ceilometer_config_jsons
- "ceilometer-notification" when:
- "ceilometer-collector" - inventory_hostname in groups[item.value.group]
- "ceilometer-api" - item.value.enabled | bool
- "ceilometer-central" with_dict: "{{ ceilometer_services }}"
- "ceilometer-compute" 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: template:
src: "{{ item }}" src: "{{ item }}"
dest: "{{ node_config_directory }}/ceilometer-api/wsgi-ceilometer-api.conf" 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/{{ inventory_hostname }}/wsgi-ceilometer-api.conf"
- "{{ node_custom_config }}/ceilometer/wsgi-ceilometer-api.conf" - "{{ node_custom_config }}/ceilometer/wsgi-ceilometer-api.conf"
- "wsgi-ceilometer-api.conf.j2" - "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 - name: Copying over ceilometer.conf
merge_configs: merge_configs:
vars: vars:
service_name: "{{ item }}" service_name: "{{ item.key }}"
sources: sources:
- "{{ role_path }}/templates/ceilometer.conf.j2" - "{{ role_path }}/templates/ceilometer.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 }}/ceilometer.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" - "{{ node_custom_config }}/ceilometer/{{ inventory_hostname }}/ceilometer.conf"
dest: "{{ node_config_directory }}/{{ item }}/ceilometer.conf" dest: "{{ node_config_directory }}/{{ item.key }}/ceilometer.conf"
with_items: register: ceilometer_confs
- "ceilometer-notification" when:
- "ceilometer-collector" - item.value.enabled | bool
- "ceilometer-api" - inventory_hostname in groups[item.value.group]
- "ceilometer-central" with_dict: "{{ ceilometer_services }}"
- "ceilometer-compute" 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 - name: Copying over event and pipeline yaml for notification service
vars:
service: "{{ ceilometer_services['ceilometer-notification'] }}"
template: template:
src: "{{ item }}.j2" src: "{{ item }}.j2"
dest: "{{ node_config_directory }}/ceilometer-notification/{{ item }}" dest: "{{ node_config_directory }}/ceilometer-notification/{{ item }}"
register: ceilometer_events
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
with_items: with_items:
- "event_definitions.yaml" - "event_definitions.yaml"
- "event_pipeline.yaml" - "event_pipeline.yaml"
- "pipeline.yaml" - "pipeline.yaml"
notify:
- Restart ceilometer-notification container
- name: Check if policies shall be overwritten - name: Check if policies shall be overwritten
local_action: stat path="{{ node_custom_config }}/ceilometer/policy.json" local_action: stat path="{{ node_custom_config }}/ceilometer/policy.json"
@ -67,12 +91,38 @@
- name: Copying over existing policy.json - name: Copying over existing policy.json
template: template:
src: "{{ node_custom_config }}/ceilometer/policy.json" src: "{{ node_custom_config }}/ceilometer/policy.json"
dest: "{{ node_config_directory }}/{{ item }}/policy.json" dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
with_items: register: ceilometer_policy_jsons
- "ceilometer-notification"
- "ceilometer-collector"
- "ceilometer-api"
- "ceilometer-central"
- "ceilometer-compute"
when: 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 - include: bootstrap.yml
when: inventory_hostname in groups['ceilometer'] when: inventory_hostname in groups['ceilometer']
- include: start.yml - name: Flush handlers
when: inventory_hostname in groups['ceilometer'] or meta: flush_handlers
inventory_hostname in groups['compute']

View File

@ -1,35 +1,10 @@
--- ---
- name: Pulling ceilometer-notification image - name: Pulling ceilometer images
kolla_docker: kolla_docker:
action: "pull_image" action: "pull_image"
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
image: "{{ ceilometer_notification_image_full }}" image: "{{ item.value.image }}"
when: inventory_hostname in groups['ceilometer-notification'] when:
- inventory_hostname in groups[item.value.group]
- name: Pulling ceilometer-api image - item.value.enabled | bool
kolla_docker: with_dict: "{{ ceilometer_services }}"
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']

View File

@ -1,84 +1,2 @@
--- ---
- 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: 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 }}"

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: bootstrap_service.yml
- include: start.yml - name: Flush handlers
meta: flush_handlers