From 9d0ccad15aa358cdc6dc2f690bf181cb8354d150 Mon Sep 17 00:00:00 2001 From: Martin Chlumsky Date: Mon, 4 Nov 2019 11:54:58 -0500 Subject: [PATCH] Fix empty match while setting supported_policy_files When supported_policy_files gets set under python 3.7 [1], the regex '(.*)' matches twice, once for the policy file name and once more for the empty string that follows the policy file name. This is new behavior under python 3.7. [2] This leads to the replacement string being written out twice resulting in something like this: "nova_policy.yamlnova_". This patch changes the regex to '(.+)' ensuring there is no match success against the empty string. [1]: - set_fact: supported_policy_files: "{{ supported_policy_format_list | map('regex_replace', '(.*)', '{{ project_name }}_\\1') | list }}" [2]: https://docs.python.org/3/library/re.html#re.sub Change-Id: Ie5278832e293364c66d53ddb07dff9c5409f0cc6 Closes-Bug: 1851249 --- ansible/roles/horizon/tasks/policy_item.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/horizon/tasks/policy_item.yml b/ansible/roles/horizon/tasks/policy_item.yml index 7e4e814be2..d8a777d207 100644 --- a/ansible/roles/horizon/tasks/policy_item.yml +++ b/ansible/roles/horizon/tasks/policy_item.yml @@ -2,7 +2,7 @@ # Update policy file name - set_fact: - supported_policy_files: "{{ supported_policy_format_list | map('regex_replace', '(.*)', '{{ project_name }}_\\1') | list }}" + supported_policy_files: "{{ supported_policy_format_list | map('regex_replace', '(.+)', '{{ project_name }}_\\1') | list }}" - name: Check if policies shall be overwritten local_action: stat path="{{ fullpath }}"