From 2a8ae618f089c03272e9f12477fdeab6fd9c8e22 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 17 Nov 2023 14:08:03 +0100 Subject: [PATCH] renamed nginx roles --- playbook.yml | 2 +- roles/docker-reverse-proxy/meta/main.yml | 2 +- roles/https-redirect/meta/main.yml | 2 -- roles/https-redirect/readme.md | 5 ---- roles/nginx-homepage/Readme.md | 4 +-- roles/nginx-homepage/meta/main.yml | 2 +- .../meta/main.yml | 0 roles/nginx-redirect/meta/main.yml | 2 ++ roles/nginx-redirect/readme.md | 29 +++++++++++++++++++ .../tasks/main.yml | 0 .../templates/redirect.domain.nginx.conf.j2 | 0 11 files changed, 36 insertions(+), 12 deletions(-) delete mode 100644 roles/https-redirect/meta/main.yml delete mode 100644 roles/https-redirect/readme.md rename roles/{https-server => nginx-https}/meta/main.yml (100%) create mode 100644 roles/nginx-redirect/meta/main.yml create mode 100644 roles/nginx-redirect/readme.md rename roles/{https-redirect => nginx-redirect}/tasks/main.yml (100%) rename roles/{https-redirect => nginx-redirect}/templates/redirect.domain.nginx.conf.j2 (100%) diff --git a/playbook.yml b/playbook.yml index 1df7eba1..9c96498e 100644 --- a/playbook.yml +++ b/playbook.yml @@ -46,7 +46,7 @@ hosts: redirect become: true roles: - - role: https-redirect + - role: nginx-redirect vars: domain_mappings: "{{redirect_domain_mappings}}" diff --git a/roles/docker-reverse-proxy/meta/main.yml b/roles/docker-reverse-proxy/meta/main.yml index 5c9a6781..03d1e23a 100644 --- a/roles/docker-reverse-proxy/meta/main.yml +++ b/roles/docker-reverse-proxy/meta/main.yml @@ -1,3 +1,3 @@ dependencies: - docker -- https-server +- nginx-https diff --git a/roles/https-redirect/meta/main.yml b/roles/https-redirect/meta/main.yml deleted file mode 100644 index f437abff..00000000 --- a/roles/https-redirect/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- https-server diff --git a/roles/https-redirect/readme.md b/roles/https-redirect/readme.md deleted file mode 100644 index b4626422..00000000 --- a/roles/https-redirect/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# native https-redirect - -## see -- https://stackoverflow.com/questions/6045020/how-to-redirect-to-a-different-domain-using-nginx -- https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html diff --git a/roles/nginx-homepage/Readme.md b/roles/nginx-homepage/Readme.md index 7990c05e..7d4d688f 100644 --- a/roles/nginx-homepage/Readme.md +++ b/roles/nginx-homepage/Readme.md @@ -7,7 +7,7 @@ This Ansible role configures an Nginx server to serve a static homepage. It hand - Ansible 2.9 or higher - Nginx installed on the target machine - Git installed on the target machine (if cloning a repo) -- `https-server` and `git` roles available or configured if they are used as dependencies +- `nginx-https` and `git` roles available or configured if they are used as dependencies ## Role Variables @@ -18,7 +18,7 @@ This Ansible role configures an Nginx server to serve a static homepage. It hand ## Dependencies -- `https-server`: A role for setting up an HTTPS server +- `nginx-https`: A role for setting up an HTTPS server - `git`: A role for installing Git ## Example Playbook diff --git a/roles/nginx-homepage/meta/main.yml b/roles/nginx-homepage/meta/main.yml index 60e983dc..a78596a0 100644 --- a/roles/nginx-homepage/meta/main.yml +++ b/roles/nginx-homepage/meta/main.yml @@ -1,3 +1,3 @@ dependencies: -- https-server +- nginx-https - git diff --git a/roles/https-server/meta/main.yml b/roles/nginx-https/meta/main.yml similarity index 100% rename from roles/https-server/meta/main.yml rename to roles/nginx-https/meta/main.yml diff --git a/roles/nginx-redirect/meta/main.yml b/roles/nginx-redirect/meta/main.yml new file mode 100644 index 00000000..49322377 --- /dev/null +++ b/roles/nginx-redirect/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: +- nginx-https diff --git a/roles/nginx-redirect/readme.md b/roles/nginx-redirect/readme.md new file mode 100644 index 00000000..79763e52 --- /dev/null +++ b/roles/nginx-redirect/readme.md @@ -0,0 +1,29 @@ +# 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. + +## Requirements + +- Ansible 2.9 or higher +- Nginx installed on the target machine +- Let's Encrypt for SSL certificate management + +## Role Variables + +- `domain_mappings`: A list of objects with `source` and `target` properties specifying the domains to redirect from and to. +- `administrator_email`: The email used for SSL certificate registration with Let's Encrypt. + +## Dependencies + +- `nginx-https`: A role for setting up HTTPS for Nginx +- `letsencrypt`: A role for managing SSL certificates with Let's Encrypt + +## Example Playbook + +```yaml +- hosts: servers + roles: + - { role: nginx-redirect, domain_mappings: [ {source: 'example.com', target: 'newdomain.com'} ] } + +## Author Information +This role was created in 2023 by Kevin Veen Birkenbach. \ No newline at end of file diff --git a/roles/https-redirect/tasks/main.yml b/roles/nginx-redirect/tasks/main.yml similarity index 100% rename from roles/https-redirect/tasks/main.yml rename to roles/nginx-redirect/tasks/main.yml diff --git a/roles/https-redirect/templates/redirect.domain.nginx.conf.j2 b/roles/nginx-redirect/templates/redirect.domain.nginx.conf.j2 similarity index 100% rename from roles/https-redirect/templates/redirect.domain.nginx.conf.j2 rename to roles/nginx-redirect/templates/redirect.domain.nginx.conf.j2