openpunk-ansible/tasks/nginx.yml

52 lines
1.3 KiB
YAML
Raw Normal View History

2022-05-31 04:36:55 +00:00
---
2022-05-30 15:46:36 +00:00
- name: Remove default nginx config
file:
name: /etc/nginx/sites-enabled
state: absent
- name: Restore sites-enabled
file:
name: /etc/nginx/sites-enabled
state: directory
- name: Install system nginx config
2022-08-02 18:38:55 +00:00
copy:
src: static/nginx/nginx.conf
2022-05-30 15:46:36 +00:00
dest: /etc/nginx/nginx.conf
# setup our configs for each host (we don't want to
# overwrite certbot's changes, so if it already exists,
# don't copy!)
2022-05-30 15:46:36 +00:00
- name: Install nginx config for {{ domain }}
template:
src: templates/nginx/site.conf
dest: /etc/nginx/conf.d/{{ domain }}.conf
force: no
2022-05-30 15:46:36 +00:00
- name: Install nginx config for git.{{ domain }}
template:
src: templates/nginx/gitea.conf
dest: /etc/nginx/conf.d/git.{{ domain }}.conf
force: no
2022-05-30 15:46:36 +00:00
- name: Install nginx config for our Hidden Service
template:
src: templates/nginx/tor.conf
dest: /etc/nginx/conf.d/tor-{{ domain }}.conf
force: no
2022-05-30 15:46:36 +00:00
2022-08-02 18:32:19 +00:00
- name: Reload Nginx to install LetsEncrypt
2022-05-30 15:46:36 +00:00
service:
name: nginx
state: restarted
# certbot is a life saver. thank you certbot devs!
2022-05-30 15:46:36 +00:00
- name: Setup certbot
shell: "certbot --nginx --non-interactive --agree-tos -m {{ contact_email }} -d {{ domain }} -d git.{{ domain }}"
2022-08-02 18:32:19 +00:00
- name: Reload Nginx with LetsEncrypt installed
2022-05-30 15:46:36 +00:00
systemd:
name: nginx
enabled: yes
state: restarted