Skip to content

Commit 1e27408

Browse files
author
Vic Shóstak
committed
Fix install_brotli playbook, Update nginx.conf
1 parent 392e2bd commit 1e27408

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Ansible is a radically simple IT automation system. It handles configuration man
7676

7777
**VS Code config hints:**
7878

79-
For better readability, please add two association to your `.vscode/settings.json`:
79+
For better readability, please add two association to your `.vscode/settings.json`:
8080

8181
1. For `Ansible` playbooks
8282
2. For `jinja2` templates (which uses for `Nginx` configs)
@@ -164,11 +164,12 @@ ansible-playbook \
164164

165165
**Features:**
166166

167+
- Added lines to files:
168+
- `load_module` lines with Brotli module to the start of Nginx config (`/etc/nginx/nginx.conf`)
167169
- Installed latest versions:
168170
- [`Brotli`](https://github.com/google/brotli)
169171
- [`Brotli module`](https://github.com/google/ngx_brotli) for Nginx
170172
- Configured by the best practice:
171-
- Nginx
172173
- Brotli
173174

174175
**Tested to work:**

configs/nginx.conf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Add Brotli modules
2-
load_module "modules/ngx_http_brotli_filter_module.so";
3-
load_module "modules/ngx_http_brotli_static_module.so";
4-
51
# Start NGINX configuration
62
worker_processes auto;
73

create_ssl-playbook.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
apt:
99
pkg: software-properties-common
1010
state: latest
11+
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release != 'focal'
1112

1213
- name: Add PPA repositories
1314
apt_repository:
1415
repo: "{{ item.repo }}"
1516
with_items:
1617
- { repo: "ppa:certbot/certbot" }
18+
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release != 'focal'
1719

1820
- name: Update dist
1921
apt:
@@ -43,11 +45,14 @@
4345
src: ./templates/http-domain.j2
4446
dest: /etc/nginx/sites-available/{{ domain }}.conf
4547

46-
- name: Create symbolic link for {{ domain }}.conf to /etc/nginx/sites-enabled/
48+
- name: Create symbolic link for {{ domain }}.conf to /etc/nginx/sites-enabled
4749
file:
4850
state: link
4951
src: /etc/nginx/sites-available/{{ domain }}.conf
50-
dest: /etc/nginx/sites-enabled/
52+
dest: /etc/nginx/sites-enabled/{{ domain }}.conf
53+
owner: "{{ ansible_user }}"
54+
group: "{{ ansible_user }}"
55+
mode: 0644
5156
notify:
5257
- restart_nginx
5358

install_brotli-playbook.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252
- { src: "~/nginx-{{ nginx_version }}/objs/ngx_http_brotli_filter_module.so", dest: "/usr/share/nginx/modules" }
5353
- { src: "~/nginx-{{ nginx_version }}/objs/ngx_http_brotli_static_module.so", dest: "/usr/share/nginx/modules" }
5454

55+
- name: Add Brotli module to start of Nginx config
56+
lineinfile:
57+
path: /etc/nginx/nginx.conf
58+
insertbefore: BOF
59+
line: "{{ item.line }}"
60+
with_items:
61+
- { line: 'load_module "modules/ngx_http_brotli_filter_module.so";' }
62+
- { line: 'load_module "modules/ngx_http_brotli_static_module.so";' }
63+
5564
- name: Copy Brotli config
5665
copy:
5766
src: "{{ item.src }}"
@@ -60,7 +69,6 @@
6069
group: "{{ ansible_user }}"
6170
mode: 0644
6271
with_items:
63-
- { src: "./configs/nginx.conf", dest: "/etc/nginx/nginx.conf" }
6472
- { src: "./configs/brotli.conf", dest: "/etc/nginx/conf.d/brotli.conf" }
6573
notify:
6674
- restart_nginx

new_vds-playbook.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
apt:
99
pkg: software-properties-common
1010
state: latest
11+
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release != 'focal'
1112

1213
- name: Add PPA repositories
1314
apt_repository:

0 commit comments

Comments
 (0)