From a374ff9f3f6c6658c0c65c3d953cbb736e42cb25 Mon Sep 17 00:00:00 2001
From: "ya.wang" <wang.ya@99cloud.net>
Date: Tue, 21 Apr 2020 16:36:33 +0800
Subject: [PATCH] Fix cyborg api failed to load api-paste.ini file

Change-Id: Id0f5809b50d0f6a0c96704e8f855d18f16f8de56
Closes-bug: #1874028
---
 ansible/roles/cyborg/tasks/config.yml          | 18 ++++--------------
 ...o-find-api-paste-file-225cec3ec16b2265.yaml |  6 ++++++
 2 files changed, 10 insertions(+), 14 deletions(-)
 create mode 100644 releasenotes/notes/fix-cyborg-api-failed-to-find-api-paste-file-225cec3ec16b2265.yaml

diff --git a/ansible/roles/cyborg/tasks/config.yml b/ansible/roles/cyborg/tasks/config.yml
index b1a8cc0840..5ca3007988 100644
--- a/ansible/roles/cyborg/tasks/config.yml
+++ b/ansible/roles/cyborg/tasks/config.yml
@@ -82,28 +82,18 @@
   notify:
     - Restart {{ item.key }} container
 
-- name: Checking whether cyborg-api-paste.ini file exists
-  vars:
-    service: "{{ cyborg_services['cyborg-api'] }}"
-  stat:
-    path: "{{ node_custom_config }}/cyborg/cyborg-api-paste.ini"
-  delegate_to: localhost
-  run_once: True
-  register: check_cyborg_api_paste_ini
-  when:
-    - service.enabled | bool
-
 - name: Copying over cyborg-api-paste.ini
   vars:
     service: "{{ cyborg_services['cyborg-api'] }}"
-  template:
-    src: "{{ node_custom_config }}/cyborg/cyborg-api-paste.ini"
+  merge_configs:
+    sources:
+      - "{{ role_path }}/templates/cyborg-api-paste.ini.j2"
+      - "{{ node_custom_config }}/cyborg/cyborg-api-paste.ini"
     dest: "{{ node_config_directory }}/cyborg-api/api-paste.ini"
     mode: "0660"
   when:
     - inventory_hostname in groups['cyborg-api']
     - service.enabled | bool
-    - check_cyborg_api_paste_ini.stat.exists
   notify:
     - Restart cyborg-api container
 
diff --git a/releasenotes/notes/fix-cyborg-api-failed-to-find-api-paste-file-225cec3ec16b2265.yaml b/releasenotes/notes/fix-cyborg-api-failed-to-find-api-paste-file-225cec3ec16b2265.yaml
new file mode 100644
index 0000000000..00d34fc1c5
--- /dev/null
+++ b/releasenotes/notes/fix-cyborg-api-failed-to-find-api-paste-file-225cec3ec16b2265.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    Fix cyborg api container failed to load api paste file. For details
+    please see `bug 1874028
+    <https://bugs.launchpad.net/kolla-ansible/+bug/1874028>`__.