Skip to content

Commit 7e6a7f0

Browse files
authored
Triple S!!! Speed, Systemd and Selinux (#272)
1 parent f3c8bd2 commit 7e6a7f0

29 files changed

+370
-111
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,6 @@ Author Information
223223

224224
[Grzegorz Dzien](https://github.com/gdzien)
225225

226+
[Tom Gamull](https://github.com/magicalyak)
227+
226228
© [NGINX, Inc.](https://www.nginx.com/) 2018 - 2020

defaults/main/main.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,18 @@ nginx_cleanup_config_path:
9494
- directory:
9595
- /etc/nginx/conf.d
9696
recurse: false
97+
98+
# Set selinux enforcing for nginx (Centos/Redhat only) - you may need to open ports on your own
99+
nginx_selinux: false
100+
# Enable enforcing mode if true. Permissive if false (audit only, no enforcing) globally (only works with nginx_selinux: true)
101+
nginx_selinux_enforcing: true
102+
# List of TCP ports to add to http_port_t type (80 and 443 have this type already)
103+
# nginx_selinux_tcp_ports:
104+
# - 80
105+
# - 443
106+
# List of UDP ports to add to http_port_t type
107+
# nginx_selinux_udp_ports:
108+
# - 80
109+
# - 443
110+
# Temporary directory to hold selinux modules
111+
nginx_tempdir: /tmp

defaults/main/systemd.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
# Enable systemd modifications
3+
# ** ALL of the following variables are ignored unless this is set to true **
4+
nginx_service_modify: false
5+
6+
# Remove the override file completely
7+
nginx_service_clean: false
8+
9+
# Override the systemd directory
10+
# Default is /etc/systemd/system/nginx.service.d
11+
nginx_service_overridepath: /etc/systemd/system/nginx.service.d
12+
13+
# Override the systemd filename
14+
# Default is override.conf
15+
nginx_service_overridefilename: override.conf
16+
17+
# Set service timeout for systemd systems in seconds (default: 90)
18+
# [Service]
19+
# TimeoutStopSec=90
20+
# Default is to comment this out
21+
# nginx_service_timeoutstopsec: 90
22+
23+
# Set the restart policy for systemd systems
24+
# Values = no (default), on-failure, on-abnormal, on-watchdog, on-abort, always
25+
# [Service]
26+
# Restart=on-failure
27+
# Default is to comment this out
28+
# nginx_service_restart: on-failure
29+
30+
# Set the restart timer in seconds
31+
# [Service]
32+
# RestartSec=5s
33+
# Default is to comment this out
34+
# nginx_service_restartsec: 5s
35+
36+
# Enable a custom systemd override file
37+
# ** This could break the service **
38+
# Setting this to true disables custom values above
39+
nginx_service_custom: false
40+
41+
# Filename and path for systemd override file
42+
# Setting this will overwrite existing override file
43+
nginx_service_custom_file: "{{ role_path }}/files/services/nginx.override.conf"

files/services/nginx.override.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Service]
2+
TimeoutStopSec=90

handlers/main.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
---
2+
# handlers file for ansible-role-nginx
3+
- name: "(Handler: All OSs) Check NGINX"
4+
command: "nginx -t"
5+
changed_when: false
6+
7+
- name: "(Handler: All OSs) systemd daemon-reload"
8+
systemd:
9+
daemon_reload: yes
10+
notify: "(Handler: All OSs) Start NGINX"
11+
212
- name: "(Handler: All OSs) Run NGINX"
313
block:
414

@@ -33,7 +43,3 @@
3343
name: unitd
3444
state: started
3545
enabled: yes
36-
37-
- name: "(Handler: All OSs) Check NGINX"
38-
command: "nginx -t"
39-
changed_when: false

molecule/common/playbook_default.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
- role: ansible-role-nginx
2626
vars:
2727
nginx_debug_output: true
28-
28+
nginx_selinux: true
29+
nginx_selinux_tcp_ports:
30+
- 80
31+
- 443
2932
nginx_version: "{{ version }}"
3033
nginx_logrotate_conf_enable: true
3134
nginx_logrotate_conf:

molecule/common/playbook_module.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
vars:
77
nginx_debug_output: true
88

9+
nginx_service_modify: true
10+
nginx_service_timeout: 95
11+
nginx_selinux: true
12+
nginx_selinux_tcp_ports:
13+
- 80
14+
- 443
15+
916
nginx_cleanup_config: true
1017
nginx_cleanup_config_path:
1118
- directory:

molecule/common/playbook_template.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
vars:
77
nginx_debug_output: true
88

9+
nginx_service_modify: true
10+
nginx_service_timeout: 95
11+
nginx_selinux: true
12+
nginx_selinux_tcp_ports:
13+
- 80
14+
- 443
15+
916
nginx_main_template_enable: true
1017
nginx_main_template:
1118
template_file: nginx.conf.j2

tasks/amplify/install-amplify.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
---
2-
- import_tasks: setup-debian.yml
3-
when: ansible_os_family == "Debian"
4-
5-
- import_tasks: setup-redhat.yml
6-
when: ansible_os_family == "RedHat"
2+
- include_tasks: "{{ role_path }}/tasks/amplify/setup-{{ ansible_os_family | lower }}.yml"
3+
when:
4+
- ansible_os_family == "Debian"
5+
or ansible_os_family == "Redhat"
76

87
- name: "(Install: All OSs) Install NGINX Amplify Agent"
98
package:

tasks/keys/setup-keys.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- name: "(Setup: Keys) Alpine"
3+
include_tasks: "{{ role_path }}/tasks/keys/apk-key.yml"
4+
when: ansible_os_family == "Alpine"
5+
tags: nginx_apkkey
6+
7+
- name: "(Setup: Keys) Debian"
8+
include_tasks: "{{ role_path }}/tasks/keys/apt-key.yml"
9+
when: ansible_os_family == "Debian"
10+
tags: nginx_aptkey
11+
12+
- name: "(Setup: Keys) RedHat/Suse"
13+
include_tasks: "{{ role_path }}/tasks/keys/rpm-key.yml"
14+
when: ansible_os_family == "RedHat"
15+
or ansible_os_family == "Suse"
16+
tags: nginx_rpmkey

0 commit comments

Comments
 (0)