mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-10 06:51:04 +01:00
Implemented redirect function for domains
This commit is contained in:
parent
d45da7497f
commit
90fa9f830f
2
roles/native-https-redirect/meta/main.yml
Normal file
2
roles/native-https-redirect/meta/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- native-https-server
|
5
roles/native-https-redirect/readme.md
Normal file
5
roles/native-https-redirect/readme.md
Normal file
@ -0,0 +1,5 @@
|
||||
# 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
|
12
roles/native-https-redirect/tasks/main.yml
Normal file
12
roles/native-https-redirect/tasks/main.yml
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: recieve redirect source certificates
|
||||
command: certbot certonly --agree-tos --email {{administrator_email}} --non-interactive --webroot -w /var/lib/letsencrypt/ -d {{item.source}}
|
||||
loop: "{{domain_mappings}}"
|
||||
|
||||
- name: configure nginx redirect configurations
|
||||
vars:
|
||||
domain: "{{item.source}}"
|
||||
target_domain: "{{item.target}}"
|
||||
template: src=redirect.domain.nginx.conf.j2 dest=/etc/nginx/conf.d/{{ domain }}.conf
|
||||
loop: "{{domain_mappings}}"
|
||||
notify: restart nginx
|
@ -0,0 +1,5 @@
|
||||
server {
|
||||
server_name {{domain}};
|
||||
{% include 'roles/native-letsencrypt/templates/ssl_header.j2' %}
|
||||
return 301 https://{{target_domain}}$request_uri;
|
||||
}
|
7
site.yml
7
site.yml
@ -60,6 +60,13 @@
|
||||
vars:
|
||||
domains: "{{wordpress_domains}}"
|
||||
http_port: 8003
|
||||
- name: setup redirect hosts
|
||||
hosts: redirect_hosts
|
||||
become: true
|
||||
roles:
|
||||
- role: native-https-redirect
|
||||
vars:
|
||||
domain_mappings: "{{redirect_domain_mappings}}"
|
||||
- name: setup mediawiki hosts
|
||||
hosts: mediawiki_hosts
|
||||
become: true
|
||||
|
Loading…
Reference in New Issue
Block a user