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 }}"
attributes:
objectClass: "{{ ldap.user_objects }}"
mail: "{{ item.value.email }}"
mail: "{{ item.value.email }}"
state: exact # exact is safest for single-valued attributes
loop: "{{ users | dict2items }}"
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:
- **Discover** existing `*.conf` vhosts in your Nginx servers directory
- **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) ⭐️
- **Clean up** leftover configs when running in cleanup mode 🧹
@ -20,5 +20,5 @@ Ensure that any request to `www.example.com` automatically and permanently redir
- **Auto-Discovery**: Scans your Nginx `servers` directory for `.conf` files. 🔍
- **Dynamic Redirects**: Builds `source: "www.domain"``target: "domain"` mappings on the fly. 🔧
- **Wildcard Redirect**: Includes a templated wildcard server block for `www.*` domains (toggleable). ✨
- **Cleanup Mode**: Removes the wildcard config file when `certbot_flavor` is set to `dedicated` and `mode_cleanup` is enabled. 🗑️
- **Cleanup Mode**: Removes the wildcard config file when `certbot_flavor` is set to `dedicated` and `mode_cleanup` is enabled. 🗑️
- **Debug Output**: Optional `enable_debug` gives detailed variable dumps for troubleshooting. 🐛

View File

@ -8,9 +8,9 @@
set_fact:
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:
name: nginx-redirect-domain
name: nginx-redirect-domains
vars:
domain_mappings: "{{ www_domains
| map('regex_replace',

View File

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