From 97cd173177c88f08e62fa4b4f57a3c34a46f1c2a Mon Sep 17 00:00:00 2001
From: Andrey Kurilin <andr.kurilin@gmail.com>
Date: Thu, 23 Nov 2023 15:24:08 +0100
Subject: [PATCH] Fix broken list concatenation in horizon role

Starting with ansible-core 2.13, list concatenation format is changed
and does not support concatenation operations outside of the jinja template.

The format change:

  "[1] + {{ [2] }}" -> "{{ [1] + [2] }}"

This affects the horizon role that iterates over existing policy files to
override and concatenate them into a single variable.

Co-Authored-By: Dr. Jens Harbott <harbott@osism.tech>

Closes-Bug: #2045660
Change-Id: I91a2101ff26cb8568f4615b4cdca52dcf09e6978
---
 ansible/roles/horizon/tasks/policy_item.yml                | 2 +-
 ...-to-override-horizon-policy-files-c405906a9faf8f3b.yaml | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 releasenotes/notes/bug-2045660-inability-to-override-horizon-policy-files-c405906a9faf8f3b.yaml

diff --git a/ansible/roles/horizon/tasks/policy_item.yml b/ansible/roles/horizon/tasks/policy_item.yml
index 7350dc7554..708f60e6ef 100644
--- a/ansible/roles/horizon/tasks/policy_item.yml
+++ b/ansible/roles/horizon/tasks/policy_item.yml
@@ -20,6 +20,6 @@
 
 - name: Update custom policy file name
   set_fact:
-    custom_policy: "{{ custom_policy }} + [ '{{ overwritten_files.results.0.stat.path }}' ]"
+    custom_policy: "{{ custom_policy + [overwritten_files.results.0.stat.path] }}"
   when:
     - overwritten_files.results
diff --git a/releasenotes/notes/bug-2045660-inability-to-override-horizon-policy-files-c405906a9faf8f3b.yaml b/releasenotes/notes/bug-2045660-inability-to-override-horizon-policy-files-c405906a9faf8f3b.yaml
new file mode 100644
index 0000000000..7e3c382a11
--- /dev/null
+++ b/releasenotes/notes/bug-2045660-inability-to-override-horizon-policy-files-c405906a9faf8f3b.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+  - |
+    Starting with ansible-core 2.13, list concatenation format is changed
+    which resulted in inability to override horizon policy files.
+    See `LP#2045660 <https://launchpad.net/bugs/2045660>`__
+    for more details.
-- 
GitLab