mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Solved mapping bugs
This commit is contained in:
@@ -5,12 +5,16 @@
|
||||
domain: "{{item.source}}"
|
||||
loop: "{{domain_mappings}}"
|
||||
|
||||
- name: The domains for which a www. redirect will be implemented
|
||||
debug:
|
||||
var: domain_mappings
|
||||
when: mode_debug | bool
|
||||
|
||||
- name: configure nginx redirect configurations
|
||||
vars:
|
||||
domain: "{{item.source}}"
|
||||
target_domain: "{{item.target}}"
|
||||
item: "{{item}}"
|
||||
template:
|
||||
src: redirect.domain.nginx.conf.j2
|
||||
dest: "{{nginx.directories.http.servers}}{{ domain }}.conf"
|
||||
loop: "{{domain_mappings}}"
|
||||
dest: "{{nginx.directories.http.servers}}{{item.source}}.conf"
|
||||
loop: "{{domain_mappings}}"
|
||||
notify: restart nginx
|
||||
|
@@ -1,5 +1,8 @@
|
||||
server {
|
||||
{% set domain = item.source %}
|
||||
{% set target = item.target %}
|
||||
server_name {{domain}};
|
||||
{% include 'roles/letsencrypt/templates/ssl_header.j2' %}
|
||||
return 301 https://{{target_domain}}$request_uri;
|
||||
|
||||
return 301 https://{{target}}$request_uri;
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@
|
||||
domain: "{{primary_domain}}"
|
||||
template:
|
||||
src: www.wildcard.conf.j2
|
||||
dest: "{{nginx_www_wildcart_configuration}}"
|
||||
dest: "{{nginx_www_wildcard_configuration}}"
|
||||
notify: restart nginx
|
||||
when: enable_wildcard_certificate | bool
|
||||
|
||||
@@ -65,21 +65,30 @@
|
||||
|
||||
|
||||
# Cleanup
|
||||
- name: Cleanup dedicated nginx configurations for www redirect configuration
|
||||
file:
|
||||
path: "{{ nginx.directories.http.servers }}{{ item.source }}.conf"
|
||||
state: absent
|
||||
loop: "{{ filtered_domains_with_primary_domain | map('regex_replace', '^(.*)$', '{ source: \"www.\\1\", target: \"\\1\" }') | map('from_yaml') | list }}"
|
||||
notify: restart nginx
|
||||
when:
|
||||
- enable_wildcard_certificate | bool
|
||||
- mode_cleanup
|
||||
# Deactivated due to complexity
|
||||
#- name: Cleanup dedicated nginx configurations for www redirect configuration
|
||||
# file:
|
||||
# path: "{{ nginx.directories.http.servers }}{{ item.source }}.conf"
|
||||
# state: absent
|
||||
# # Filter: Only first-level subdomains of primary_domain
|
||||
# # Exclude the primary domain itself
|
||||
# # Transform for www redirection
|
||||
# loop: "{{ filtered_domains_with_primary_domain
|
||||
# | select('regex_search', '^[^.]+\\.' ~ primary_domain ~ '$')
|
||||
# | reject('equalto', primary_domain)
|
||||
# | map('regex_replace', '^(.*)$', '{ source: \"www.\\1\", target: \"\\1\" }')
|
||||
# | map('from_yaml')
|
||||
# | list }}"
|
||||
# notify: restart nginx
|
||||
# when:
|
||||
# - enable_wildcard_certificate | bool # Wildcard certificate must be enabled
|
||||
# - mode_cleanup | bool # Cleanup mode must be enabled
|
||||
|
||||
- name: Cleanup {{nginx_www_wildcart_configuration}}
|
||||
- name: Cleanup {{nginx_www_wildcard_configuration}}
|
||||
file:
|
||||
path: "{{nginx_www_wildcart_configuration}}"
|
||||
path: "{{nginx_www_wildcard_configuration}}"
|
||||
state: absent
|
||||
notify: restart nginx
|
||||
when:
|
||||
- not enable_wildcard_certificate | bool
|
||||
- mode_cleanup
|
||||
- mode_cleanup | bool
|
||||
|
@@ -1 +1 @@
|
||||
nginx_www_wildcart_configuration: "{{nginx.directories.http.global}}www.wildcard.conf"
|
||||
nginx_www_wildcard_configuration: "{{nginx.directories.http.global}}www.wildcard.conf"
|
Reference in New Issue
Block a user