infrastructure/ansible/roles/nginx/tasks/main.yml

66 lines
1.4 KiB
YAML
Raw Normal View History

- name: Install nginx
package:
name: "{{ 'nginx-mainline' if ansible_os_family == 'Archlinux' else 'nginx' }}"
become: true
2023-12-20 22:35:11 +00:00
- name: Install nginx modules
2023-12-16 21:57:19 +00:00
package:
2023-12-20 22:35:11 +00:00
name: "{{ item }}"
loop:
- libnginx-mod-http-headers-more-filter
- libnginx-mod-http-brotli-filter
- libnginx-mod-stream
2023-12-17 18:12:33 +00:00
when: ansible_os_family != 'Archlinux'
become: true
2023-12-20 22:35:11 +00:00
- name: Install nginx modules (on Arch)
2023-12-17 18:12:33 +00:00
kewlfft.aur.aur:
2023-12-20 22:35:11 +00:00
name: "{{ item }}"
loop:
- nginx-mainline-mod-headers-more
- nginx-mainline-mod-brotli
2023-12-17 18:12:33 +00:00
when: ansible_os_family == 'Archlinux'
become: true
- name: Generate Diffie-Hellman parameters
community.crypto.openssl_dhparam:
path: /etc/nginx/dhparams.pem
become: true
- name: Create config directories
file:
path: /etc/nginx/{{ item }}
state: directory
mode: "0755"
loop:
- http.d
- stream.d
- includes
become: true
- name: Copy config files
template:
src: "{{ item }}"
dest: /etc/nginx/includes/{{ item | basename }}
mode: "0644"
with_fileglob: files/includes/*.conf
become: true
notify: reload nginx
- name: Install config
template:
src: files/nginx.conf
dest: /etc/nginx/nginx.conf
mode: "0644"
become: true
notify: reload nginx
- name: Install HTTPS redirect
template:
src: files/nginx-https-redirect.conf
dest: /etc/nginx/http.d/https-redirect.conf
mode: "0644"
become: true
notify: reload nginx
when: nginx_https_redirect