2021-09-18 19:37:57 +00:00
|
|
|
---
|
|
|
|
- name: Install Nginx
|
2023-08-29 18:56:08 +00:00
|
|
|
notify: nginx | Restart Nginx
|
2021-09-18 19:37:57 +00:00
|
|
|
apt:
|
2023-08-29 18:56:08 +00:00
|
|
|
name:
|
|
|
|
- libnginx-mod-http-geoip
|
2023-08-30 12:12:15 +00:00
|
|
|
- libnginx-mod-http-geoip2
|
2024-01-04 02:49:38 +00:00
|
|
|
- libnginx-mod-stream
|
2023-08-29 18:56:08 +00:00
|
|
|
- nginx
|
2021-09-18 19:37:57 +00: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 12:30:47 +00:00
|
|
|
- '{{ nginx__dir_etc }}'
|
2021-09-18 19:37:57 +00:00
|
|
|
- '{{ nginx__confd_dir }}'
|
|
|
|
- '{{ nginx__available_dir }}'
|
|
|
|
- '{{ nginx__enabled_dir }}'
|
|
|
|
- '{{ nginx__snippets_dir }}'
|
|
|
|
|
2023-05-29 13:14:15 +00: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 06:20:55 +00:00
|
|
|
- name: Install Nginx config
|
2021-09-18 19:37:57 +00:00
|
|
|
notify: nginx | Restart Nginx
|
2023-08-12 17:18:43 +00:00
|
|
|
template:
|
|
|
|
src: 'templates/nginx.conf'
|
2023-05-29 12:30:47 +00:00
|
|
|
dest: '{{ nginx__dir_etc }}/nginx.conf'
|
2023-03-30 06:20:55 +00:00
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
2021-09-18 19:37:57 +00:00
|
|
|
|
2023-08-29 18:56:08 +00:00
|
|
|
- name: Install Nginx configs
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
template:
|
2023-08-30 12:12:15 +00:00
|
|
|
src: 'templates/conf.d/geoip.conf'
|
2023-08-29 18:56:08 +00:00
|
|
|
dest: '{{ nginx__confd_dir }}/geoip.conf'
|
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
2023-03-30 06:26:01 +00:00
|
|
|
- name: Install Nginx stream config
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
copy:
|
2023-03-30 06:52:59 +00:00
|
|
|
content: "{{ nginx__stream }}\n"
|
2023-05-29 12:30:47 +00:00
|
|
|
dest: '{{ nginx__dir_etc }}/stream.conf'
|
2023-03-30 06:26:01 +00:00
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
2021-09-18 19:37:57 +00: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 04:38:05 +00:00
|
|
|
src: 'templates/upstream.conf'
|
2021-09-18 19:37:57 +00: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 04:39:11 +00:00
|
|
|
src: 'templates/site.conf'
|
2021-09-18 19:37:57 +00: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 13:14:15 +00:00
|
|
|
|
2023-08-17 10:59:09 +00:00
|
|
|
- name: Install additional files
|
2023-05-29 13:14:15 +00: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 10:59:09 +00:00
|
|
|
- name: Install additional snippets
|
2023-05-29 13:14:15 +00:00
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
template:
|
2023-08-17 12:27:22 +00:00
|
|
|
src: 'templates/snippets/{{ item }}.conf'
|
2023-08-17 10:59:09 +00:00
|
|
|
dest: '{{ nginx__snippets_dir }}/{{ item }}.conf'
|
2023-05-29 13:14:15 +00:00
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
2023-08-17 10:59:09 +00:00
|
|
|
with_items:
|
|
|
|
- 'maintenance'
|