mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-04-30 02:58:38 +02:00
Solved certificate bug
This commit is contained in:
parent
e5e394d470
commit
25952fc7e9
@ -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
|
|
@ -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;
|
|
||||||
}
|
|
7
roles/nginx-redirect-domains/tasks/main.yml
Normal file
7
roles/nginx-redirect-domains/tasks/main.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
- name: "Include domains redirects"
|
||||||
|
include_tasks: redirect-domain.yml
|
||||||
|
vars:
|
||||||
|
domain: "{{ item.source }}"
|
||||||
|
target: "{{ item.target }}"
|
||||||
|
loop: "{{domain_mappings}}"
|
9
roles/nginx-redirect-domains/tasks/redirect-domain.yml
Normal file
9
roles/nginx-redirect-domains/tasks/redirect-domain.yml
Normal 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
|
@ -0,0 +1,6 @@
|
|||||||
|
server {
|
||||||
|
server_name {{ domain }};
|
||||||
|
{% include 'roles/letsencrypt/templates/ssl_header.j2' %}
|
||||||
|
|
||||||
|
return 301 https://{{ target }}$request_uri;
|
||||||
|
}
|
@ -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 🧹
|
||||||
|
|
||||||
|
@ -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',
|
||||||
|
@ -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}}"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user