computer-playbook/roles/nginx/tasks/main.yml

56 lines
1.4 KiB
YAML

---
- name: install nginx
pacman: name=nginx state=present
notify: restart nginx
when: run_once_nginx is not defined
- name: install nginx-mod-headers-more for matomo
pacman:
name: nginx-mod-headers-more
state: present
notify: restart nginx
when: run_once_nginx is not defined and nginx_matomo_tracking | bool
- name: Ensure nginx configuration directories are present
file:
path: "{{ item }}"
state: directory
mode: '0755'
loop:
- "{{nginx_servers_directory}}"
- "{{nginx_maps_directory}}"
- "{{nginx_upstreams_directory}}"
when: run_once_nginx is not defined
- name: create nginx config file
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
notify: restart nginx
when: run_once_nginx is not defined
- name: "include task certbot-matomo.yml"
include_tasks: certbot-matomo.yml
when: run_once_nginx is not defined
vars:
domain: "{{top_domain}}"
when: run_once_nginx is not defined
- name: configure {{top_domain}}.conf
template:
src: "homepage.nginx.conf.j2"
dest: "{{nginx_servers_directory}}{{top_domain}}.conf"
vars:
domain: "{{top_domain}}"
notify: restart nginx
when: run_once_nginx is not defined
- name: flush nginx service
meta: flush_handlers
when: run_once_nginx is not defined
- name: run the nginx tasks once
set_fact:
run_once_nginx: true
when: run_once_nginx is not defined