2020-02-11 04:16:57 -06:00
|
|
|
#!/usr/bin/ansible-playbook
|
|
|
|
# vim:ft=ansible:
|
|
|
|
---
|
|
|
|
- name: Set up redirect
|
|
|
|
block:
|
|
|
|
- name: Set up Apache
|
|
|
|
block:
|
|
|
|
# Why does a redirect need a webroot?
|
|
|
|
# Answer: SSL certification
|
|
|
|
- name: Create webroot
|
|
|
|
file:
|
|
|
|
path: "{{ redirect_webroot }}"
|
|
|
|
mode: "0755"
|
|
|
|
recurse: yes
|
|
|
|
state: directory
|
|
|
|
- name: Register certificates
|
|
|
|
block:
|
|
|
|
- name: Configure temporary virtual host configs
|
|
|
|
template:
|
|
|
|
src: apache2-vhost.conf
|
2020-02-11 04:20:25 -06:00
|
|
|
dest: "/etc/apache2/sites-enabled/{{ redirect_from }}.conf"
|
2020-02-11 04:16:57 -06:00
|
|
|
- name: Generate certificate
|
|
|
|
include_role:
|
|
|
|
name: https
|
|
|
|
vars:
|
2020-02-11 04:22:50 -06:00
|
|
|
website_url: "{{ redirect_from }}"
|
2020-02-11 04:16:57 -06:00
|
|
|
website_webroot: "{{ redirect_webroot }}"
|
|
|
|
- name: Configure Apache
|
|
|
|
block:
|
|
|
|
# If we copied over http-only configs before, they get oblooterated now
|
|
|
|
- name: Copy over redirect config
|
|
|
|
template:
|
|
|
|
src: apache2-redirect.conf
|
2020-02-11 04:20:25 -06:00
|
|
|
dest: "/etc/apache2/sites-enabled/{{ redirect_from }}.conf"
|
2020-02-11 04:16:57 -06:00
|
|
|
- name: Reload Apache
|
|
|
|
service:
|
|
|
|
name: apache2
|
|
|
|
state: reloaded
|
|
|
|
enabled: true
|
|
|
|
become: yes
|