mirror of
https://github.com/CPunch/openpunk-ansible.git
synced 2024-11-22 07:20:05 +00:00
roles/nginx: made idempotent
This commit is contained in:
parent
5e2c4850e1
commit
1028023b8b
4
roles/nginx/handlers/main.yml
Normal file
4
roles/nginx/handlers/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- name: setup-nginx
|
||||||
|
include_tasks: setup.yml
|
||||||
|
listen: "setup nginx"
|
@ -1,21 +1,9 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
# TODO: make idempotent
|
|
||||||
- name: Remove default nginx config
|
|
||||||
file:
|
|
||||||
name: /etc/nginx/sites-enabled
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
# TODO: make idempotent
|
|
||||||
- name: Restore sites-enabled
|
|
||||||
file:
|
|
||||||
name: /etc/nginx/sites-enabled
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
- name: Install system nginx config
|
- name: Install system nginx config
|
||||||
copy:
|
copy:
|
||||||
src: nginx.conf
|
src: nginx.conf
|
||||||
dest: /etc/nginx/nginx.conf
|
dest: /etc/nginx/nginx.conf
|
||||||
|
notify: setup nginx
|
||||||
|
|
||||||
# setup our configs for each host (we don't want to
|
# setup our configs for each host (we don't want to
|
||||||
# overwrite certbot's changes, so if it already exists,
|
# overwrite certbot's changes, so if it already exists,
|
||||||
@ -26,30 +14,24 @@
|
|||||||
src: templates/site.conf
|
src: templates/site.conf
|
||||||
dest: /etc/nginx/conf.d/{{ domain }}.conf
|
dest: /etc/nginx/conf.d/{{ domain }}.conf
|
||||||
force: no
|
force: no
|
||||||
|
notify: setup nginx
|
||||||
|
|
||||||
- name: Install nginx config for git.{{ domain }}
|
- name: Install nginx config for git.{{ domain }}
|
||||||
template:
|
template:
|
||||||
src: templates/gitea.conf
|
src: templates/gitea.conf
|
||||||
dest: /etc/nginx/conf.d/git.{{ domain }}.conf
|
dest: /etc/nginx/conf.d/git.{{ domain }}.conf
|
||||||
force: no
|
force: no
|
||||||
|
notify: setup nginx
|
||||||
|
|
||||||
- name: Install nginx config for our Hidden Service
|
- name: Install nginx config for our Hidden Service
|
||||||
template:
|
template:
|
||||||
src: templates/tor.conf
|
src: templates/tor.conf
|
||||||
dest: /etc/nginx/conf.d/tor-{{ domain }}.conf
|
dest: /etc/nginx/conf.d/tor-{{ domain }}.conf
|
||||||
force: no
|
force: no
|
||||||
|
notify: setup nginx
|
||||||
|
|
||||||
- name: Reload Nginx to install LetsEncrypt
|
- name: Enable Nginx
|
||||||
service:
|
|
||||||
name: nginx
|
|
||||||
state: restarted
|
|
||||||
|
|
||||||
# certbot is a life saver. thank you certbot devs!
|
|
||||||
- name: Setup certbot
|
|
||||||
shell: "certbot --nginx --non-interactive --agree-tos -m {{ contact_email }} -d {{ domain }} -d git.{{ domain }}"
|
|
||||||
|
|
||||||
- name: Reload Nginx with LetsEncrypt installed
|
|
||||||
systemd:
|
systemd:
|
||||||
name: nginx
|
name: nginx
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: restarted
|
state: started
|
9
roles/nginx/tasks/setup.yml
Normal file
9
roles/nginx/tasks/setup.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: Setup certbot
|
||||||
|
shell: "certbot --nginx --non-interactive --agree-tos -m {{ contact_email }} -d {{ domain }} -d git.{{ domain }}"
|
||||||
|
|
||||||
|
- name: Reload Nginx
|
||||||
|
systemd:
|
||||||
|
name: nginx
|
||||||
|
enabled: yes
|
||||||
|
state: restarted
|
Loading…
Reference in New Issue
Block a user