Solved certificate bug

This commit is contained in:
Kevin Veen-Birkenbach 2025-04-29 03:01:45 +02:00
parent e5e394d470
commit 25952fc7e9
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E
11 changed files with 28 additions and 35 deletions

View File

@ -91,7 +91,7 @@
bind_pw: "{{ ldap.bind_credential }}" bind_pw: "{{ ldap.bind_credential }}"
attributes: attributes:
objectClass: "{{ ldap.user_objects }}" objectClass: "{{ ldap.user_objects }}"
mail: "{{ item.value.email }}" mail: "{{ item.value.email }}"
state: exact # exact is safest for single-valued attributes state: exact # exact is safest for single-valued attributes
loop: "{{ users | dict2items }}" loop: "{{ users | dict2items }}"
loop_control: loop_control:

View File

@ -1,21 +0,0 @@
---
- name: "include task receive certbot certificate"
include_role:
name: nginx-https-get-cert
vars:
domain: "{{item.source}}"
loop: "{{domain_mappings}}"
- name: The domains for which a www. redirect will be implemented
debug:
var: domain_mappings
when: enable_debug | bool
- name: configure nginx redirect configurations
vars:
item: "{{item}}"
template:
src: redirect.domain.nginx.conf.j2
dest: "{{nginx.directories.http.servers}}{{item.source}}.conf"
loop: "{{domain_mappings}}"
notify: restart nginx

View File

@ -1,8 +0,0 @@
server {
{% set domain = item.source %}
{% set target = item.target %}
server_name {{domain}};
{% include 'roles/letsencrypt/templates/ssl_header.j2' %}
return 301 https://{{target}}$request_uri;
}

View File

@ -0,0 +1,7 @@
---
- name: "Include domains redirects"
include_tasks: redirect-domain.yml
vars:
domain: "{{ item.source }}"
target: "{{ item.target }}"
loop: "{{domain_mappings}}"

View File

@ -0,0 +1,9 @@
- name: "include task receive certbot certificate"
include_role:
name: nginx-https-get-cert
- name: configure nginx redirect configurations
template:
src: redirect.domain.nginx.conf.j2
dest: "{{ nginx.directories.http.servers }}{{ domain }}.conf"
notify: restart nginx

View File

@ -0,0 +1,6 @@
server {
server_name {{ domain }};
{% include 'roles/letsencrypt/templates/ssl_header.j2' %}
return 301 https://{{ target }}$request_uri;
}

View File

@ -7,7 +7,7 @@ Automates the creation of Nginx server blocks that redirect all `www.` subdomain
This role will: This role will:
- **Discover** existing `*.conf` vhosts in your Nginx servers directory - **Discover** existing `*.conf` vhosts in your Nginx servers directory
- **Filter** domains with or without your `primary_domain` - **Filter** domains with or without your `primary_domain`
- **Generate** redirect rules via the `nginx-redirect-domain` role - **Generate** redirect rules via the `nginx-redirect-domains` role
- **Optionally** include a wildcard redirect template (experimental) ⭐️ - **Optionally** include a wildcard redirect template (experimental) ⭐️
- **Clean up** leftover configs when running in cleanup mode 🧹 - **Clean up** leftover configs when running in cleanup mode 🧹

View File

@ -8,9 +8,9 @@
set_fact: set_fact:
www_domains: "{{ all_domains | select('match', '^www\\.') | list }}" www_domains: "{{ all_domains | select('match', '^www\\.') | list }}"
- name: Include nginx-redirect-domain role for www-to-bare redirects - name: Include nginx-redirect-domains role for www-to-bare redirects
include_role: include_role:
name: nginx-redirect-domain name: nginx-redirect-domains
vars: vars:
domain_mappings: "{{ www_domains domain_mappings: "{{ www_domains
| map('regex_replace', | map('regex_replace',

View File

@ -237,7 +237,7 @@
- name: setup redirect hosts - name: setup redirect hosts
when: ("redirect" in group_names) when: ("redirect" in group_names)
include_role: include_role:
name: nginx-redirect-domain name: nginx-redirect-domains
vars: vars:
domain_mappings: "{{redirect_domain_mappings}}" domain_mappings: "{{redirect_domain_mappings}}"