From 5782a214e9fce9a9ea00e48f0c065375d841978d Mon Sep 17 00:00:00 2001
From: Bertrand Lallau <bertrand.lallau@thalesgroup.com>
Date: Thu, 30 Mar 2017 11:59:07 +0200
Subject: [PATCH] Karbor services restarting issue on conf update

In case of karbor-protection providers.d/openstack-infra.conf config file modification,
karbor-operationengine and karbor-api are restarted too, but they should
not.

karbor-operationengine startup command:
https://github.com/openstack/kolla-ansible/blob/master/ansible/roles/karbor/templates/karbor-operationengine.json.j2#L2

karbor-api startup command:
https://github.com/openstack/kolla-ansible/blob/master/ansible/roles/karbor/templates/karbor-api.json.j2#L2

Change-Id: I91a0273ccf46e340315cf885ea01db6e14653182
Closes-Bug: #1677542
---
 ansible/roles/karbor/handlers/main.yml |  2 --
 ansible/roles/karbor/tasks/config.yml  | 12 +++++-------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/ansible/roles/karbor/handlers/main.yml b/ansible/roles/karbor/handlers/main.yml
index a179280c39..32dbcee361 100644
--- a/ansible/roles/karbor/handlers/main.yml
+++ b/ansible/roles/karbor/handlers/main.yml
@@ -18,7 +18,6 @@
     - service.enabled | bool
     - config_json.changed | bool
       or karbor_conf.changed | bool
-      or openstack_infra_conf.changed | bool
       or karbor_api_container.changed | bool
 
 - name: Restart karbor-protection container
@@ -62,5 +61,4 @@
     - service.enabled | bool
     - config_json.changed | bool
       or karbor_conf.changed | bool
-      or openstack_infra_conf.changed | bool
       or karbor_operationengine_container.changed | bool
diff --git a/ansible/roles/karbor/tasks/config.yml b/ansible/roles/karbor/tasks/config.yml
index 5ff24ebb93..471e414a77 100644
--- a/ansible/roles/karbor/tasks/config.yml
+++ b/ansible/roles/karbor/tasks/config.yml
@@ -48,19 +48,17 @@
 
 - name: Copying over openstack-infra.conf
   vars:
-    service: "{{ item.key }}"
+    service_name: 'karbor-protection'
+    service: "{{ karbor_services[service_name] }}"
   template:
     src: "providers.d/openstack-infra.conf.j2"
-    dest: "{{ node_config_directory }}/{{ item.key }}/providers.d/openstack-infra.conf"
+    dest: "{{ node_config_directory }}/{{ service_name }}/providers.d/openstack-infra.conf"
   register: openstack_infra_conf
   when:
-    - inventory_hostname in groups[item.value.group]
-    - item.value.enabled | bool
-  with_dict: "{{ karbor_services }}"
+    - inventory_hostname in groups[service.group]
+    - service.enabled | bool
   notify:
-    - Restart karbor-api container
     - Restart karbor-protection container
-    - Restart karbor-operationengine container
 
 - name: Check karbor containers
   kolla_docker: