Huge role refactoring/cleanup. Other commits will propably follow. Because some bugs will exist. Still important for longrun and also for auto docs/help/slideshow generation

This commit is contained in:
2025-07-08 23:43:13 +02:00
parent 6b87a049d4
commit 563d5fd528
1242 changed files with 2301 additions and 1355 deletions

View File

@@ -0,0 +1,16 @@
# Nginx Redirect Role
This Ansible role configures Nginx to perform 301 redirects from one domain to another. It handles SSL certificate retrieval for the source domains and sets up the Nginx configuration to redirect to the specified target domains.
## Role Variables
- `domain_mappings`: A list of objects with `source` and `target` properties specifying the domains to redirect from and to.
- `users.administrator.email`: The email used for SSL certificate registration with Let's Encrypt.
## Dependencies
- `webserver-https`: A role for setting up HTTPS for Nginx
- `letsencrypt`: A role for managing SSL certificates with Let's Encrypt
## Author Information
This role was created in 2023 by [Kevin Veen-Birkenbach](https://www.veen.world/).

View File

@@ -0,0 +1,2 @@
dependencies:
- webserver-https

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: webserver-tls-core
- name: "Deploying NGINX redirect configuration for {{ domain }}"
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;
}