---
- 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 }}"
    ceilometer_pipeline: "{{ ceilometer_pipelines.results|selectattr('item.key', 'equalto', service_name)|first }}"
    policy_overwriting: "{{ ceilometer_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
    polling_overwriting: "{{ ceilometer_polling_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
    ceilometer_notification_container: "{{ check_ceilometer_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
    panko_conf: "{{ panko_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
  become: true
  kolla_docker:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "{{ service.container_name }}"
    image: "{{ service.image }}"
    volumes: "{{ service.volumes|reject('equalto', '')|list }}"
    dimensions: "{{ service.dimensions }}"
  when:
    - kolla_action != "config"
    - inventory_hostname in groups[service.group]
    - service.enabled | bool
    - config_json.changed | bool
      or ceilometer_conf.changed | bool
      or policy_overwriting.changed | bool
      or ceilometer_events.changed | bool
      or ceilometer_pipeline.changed | bool
      or ceilometer_notification_container.changed | bool
      or panko_conf.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 }}"
    ceilometer_pipeline: "{{ ceilometer_pipelines.results|selectattr('item.key', 'equalto', service_name)|first }}"
    policy_overwriting: "{{ ceilometer_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
    polling_overwriting: "{{ ceilometer_polling_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
    ceilometer_central_container: "{{ check_ceilometer_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
  become: true
  kolla_docker:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "{{ service.container_name }}"
    image: "{{ service.image }}"
    volumes: "{{ service.volumes|reject('equalto', '')|list }}"
    dimensions: "{{ service.dimensions }}"
  when:
    - kolla_action != "config"
    - inventory_hostname in groups[service.group]
    - service.enabled | bool
    - config_json.changed | bool
      or ceilometer_conf.changed | bool
      or ceilometer_pipeline.changed | bool
      or policy_overwriting.changed | bool
      or ceilometer_central_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 }}"
    ceilometer_pipeline: "{{ ceilometer_pipelines.results|selectattr('item.key', 'equalto', service_name)|first }}"
    policy_overwriting: "{{ ceilometer_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
    polling_overwriting: "{{ ceilometer_polling_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
    ceilometer_compute_container: "{{ check_ceilometer_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
  become: true
  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|reject('equalto', '')|list }}"
    dimensions: "{{ service.dimensions }}"
  when:
    - kolla_action != "config"
    - inventory_hostname in groups[service.group]
    - service.enabled | bool
    - config_json.changed | bool
      or ceilometer_conf.changed | bool
      or ceilometer_pipeline.changed | bool
      or policy_overwriting.changed | bool
      or vcenter_ca_file.changed | bool
      or ceilometer_compute_container.changed | bool
