From 4d3a6128c910509629d964b2f58db11c9e440804 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 12 Dec 2023 15:50:57 +0100 Subject: [PATCH] Solved regex bug --- roles/nginx-www-redirect/tasks/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/nginx-www-redirect/tasks/main.yml b/roles/nginx-www-redirect/tasks/main.yml index 75870003..26ff27ed 100644 --- a/roles/nginx-www-redirect/tasks/main.yml +++ b/roles/nginx-www-redirect/tasks/main.yml @@ -7,9 +7,10 @@ - name: Filter domain names and remove .conf extension and path set_fact: - filtered_domains: "{{ conf_files.files | map(attribute='path') | map('regex_search', domain_regex) | select('string') | map('regex_replace', '^{{nginx_servers_directory}}', '') | map('regex_replace', '.conf$', '') | list }}" + filtered_domains: "{{ conf_files.files | map(attribute='path') | map('regex_search', domain_regex) | select('string') | map('regex_replace', path_regex, '') | map('regex_replace', '.conf$', '') | list }}" vars: - domain_regex: '^{{nginx_servers_directory}}(?!www\.)[^/]+\.conf$' + domain_regex: "^{{ nginx_servers_directory }}(?!www\\.)[^/]+\\.conf$" + path_regex: "^{{ nginx_servers_directory }}" - name: The domains for which a www. redirect will be implemented debug: