2021-09-18 15:37:57 -04:00
|
|
|
---
|
|
|
|
- name: Install Nginx
|
2023-08-29 14:56:08 -04:00
|
|
|
notify: nginx | Restart Nginx
|
2021-09-18 15:37:57 -04:00
|
|
|
apt:
|
2023-08-29 14:56:08 -04:00
|
|
|
name:
|
|
|
|
- libnginx-mod-http-geoip
|
2023-08-30 08:12:15 -04:00
|
|
|
- libnginx-mod-http-geoip2
|
2023-08-29 14:56:08 -04:00
|
|
|
- nginx
|
2021-09-18 15:37:57 -04:00
|
|
|
|
|
|
|
- name: Create directories for Nginx configuration
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: '{{ item }}'
|
|
|
|
mode: 'u=rwx,go=rx'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items:
|
2023-05-29 08:30:47 -04:00
|
|
|
- '{{ nginx__dir_etc }}'
|
2021-09-18 15:37:57 -04:00
|
|
|
- '{{ nginx__confd_dir }}'
|
|
|
|
- '{{ nginx__available_dir }}'
|
|
|
|
- '{{ nginx__enabled_dir }}'
|
|
|
|
- '{{ nginx__snippets_dir }}'
|
|
|
|
|
2023-05-29 09:14:15 -04:00
|
|
|
- name: Create directories for Nginx HTML files
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: '{{ item }}'
|
|
|
|
mode: 'u=rwx,go=rx'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items:
|
|
|
|
- '{{ nginx__dir_www }}'
|
|
|
|
- '{{ nginx__dir_www_html }}'
|
|
|
|
|
2023-03-30 02:20:55 -04:00
|
|
|
- name: Install Nginx config
|
2021-09-18 15:37:57 -04:00
|
|
|
notify: nginx | Restart Nginx
|
2023-08-12 13:18:43 -04:00
|
|
|
template:
|
|
|
|
src: 'templates/nginx.conf'
|
2023-05-29 08:30:47 -04:00
|
|
|
dest: '{{ nginx__dir_etc }}/nginx.conf'
|
2023-03-30 02:20:55 -04:00
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
2021-09-18 15:37:57 -04:00
|
|
|
|
2023-08-29 14:56:08 -04:00
|
|
|
- name: Install Nginx configs
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
template:
|
2023-08-30 08:12:15 -04:00
|
|
|
src: 'templates/conf.d/geoip.conf'
|
2023-08-29 14:56:08 -04:00
|
|
|
dest: '{{ nginx__confd_dir }}/geoip.conf'
|
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
2023-03-30 02:26:01 -04:00
|
|
|
- name: Install Nginx stream config
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
copy:
|
2023-03-30 02:52:59 -04:00
|
|
|
content: "{{ nginx__stream }}\n"
|
2023-05-29 08:30:47 -04:00
|
|
|
dest: '{{ nginx__dir_etc }}/stream.conf'
|
2023-03-30 02:26:01 -04:00
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
2021-09-18 15:37:57 -04:00
|
|
|
- name: Remove Nginx default site
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: '{{ nginx__enabled_dir }}/default'
|
|
|
|
when: nginx__remove_default|bool
|
|
|
|
|
|
|
|
- name: Add Nginx upstreams
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
template:
|
2021-09-20 00:38:05 -04:00
|
|
|
src: 'templates/upstream.conf'
|
2021-09-18 15:37:57 -04:00
|
|
|
dest: '{{ nginx__confd_dir }}/upstream-{{ item.name }}.conf'
|
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items: '{{ nginx__upstreams }}'
|
|
|
|
|
|
|
|
- name: Add Nginx sites
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
template:
|
2021-09-20 00:39:11 -04:00
|
|
|
src: 'templates/site.conf'
|
2021-09-18 15:37:57 -04:00
|
|
|
dest: '{{ nginx__available_dir }}/{{ item.domain }}.conf'
|
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items: '{{ nginx__sites }}'
|
|
|
|
|
|
|
|
- name: Enable Nginx sites
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
file:
|
|
|
|
state: link
|
|
|
|
src: '{{ nginx__available_dir }}/{{ item.domain }}.conf'
|
|
|
|
dest: '{{ nginx__enabled_dir }}/{{ item.domain }}.conf'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items: '{{ nginx__sites }}'
|
2023-05-29 09:14:15 -04:00
|
|
|
|
2023-08-17 06:59:09 -04:00
|
|
|
- name: Install additional files
|
2023-05-29 09:14:15 -04:00
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
copy:
|
|
|
|
src: 'files/{{ item }}'
|
|
|
|
dest: '{{ nginx__dir_www_html }}/{{ item }}'
|
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items:
|
|
|
|
- 'maintenance.html'
|
|
|
|
- 'maintenance.jpg'
|
|
|
|
|
2023-08-17 06:59:09 -04:00
|
|
|
- name: Install additional snippets
|
2023-05-29 09:14:15 -04:00
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
template:
|
2023-08-17 08:27:22 -04:00
|
|
|
src: 'templates/snippets/{{ item }}.conf'
|
2023-08-17 06:59:09 -04:00
|
|
|
dest: '{{ nginx__snippets_dir }}/{{ item }}.conf'
|
2023-05-29 09:14:15 -04:00
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
2023-08-17 06:59:09 -04:00
|
|
|
with_items:
|
|
|
|
- 'maintenance'
|