Skip to content

Commit 78c21d4

Browse files
authored
Add variable to set location of NGINX status conf file (#184)
1 parent 7785bab commit 78c21d4

File tree

5 files changed

+40
-30
lines changed

5 files changed

+40
-30
lines changed

README.md

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,33 @@ Alpine:
2424
versions:
2525
- 3.8
2626
- 3.9
27+
- 3.10
2728
CentOS:
28-
versions:
29-
- 6
30-
- 7.4+
31-
RedHat:
3229
versions:
3330
- 6
3431
- 7.4+
3532
- 8
3633
Debian:
3734
versions:
38-
- jessie
3935
- stretch
4036
- buster
41-
Ubuntu:
37+
FreeBSD:
4238
versions:
43-
- xenial
44-
- bionic
39+
- 11.2+
40+
- 12
41+
RedHat:
42+
versions:
43+
- 6
44+
- 7.4+
45+
- 8
4546
SUSE/SLES:
4647
versions:
4748
- 12
4849
- 15
49-
FreeBSD:
50+
Ubuntu:
5051
versions:
51-
- 11.2+
52-
- 12
52+
- xenial
53+
- bionic
5354
```
5455
5556
**NGINX Plus**
@@ -59,6 +60,7 @@ Alpine:
5960
versions:
6061
- 3.8
6162
- 3.9
63+
- 3.10
6264
Amazon Linux:
6365
versions:
6466
- 2018.03
@@ -69,9 +71,9 @@ CentOS:
6971
versions:
7072
- 6.5+
7173
- 7.4+
74+
- 8
7275
Debian:
7376
versions:
74-
- jessie
7577
- stretch
7678
- buster
7779
FreeBSD:
@@ -97,7 +99,7 @@ Ubuntu:
9799
- bionic
98100
```
99101
100-
**NGINX Amplify**
102+
**NGINX Amplify Agent**
101103
102104
```yaml
103105
Amazon Linux:
@@ -122,7 +124,7 @@ RedHat:
122124
- 7
123125
```
124126
125-
**NGINX Controller**
127+
**NGINX Controller Agent**
126128
127129
```yaml
128130
Amazon Linux:
@@ -199,10 +201,13 @@ nginx_start: true
199201
# Print NGINX configuration file to terminal after executing playbook.
200202
nginx_debug_output: false
201203

202-
# Specify which version of NGINX you want to install.
204+
# Specify which type of NGINX you want to install.
203205
# Options are 'opensource' or 'plus'.
204206
# Default is 'opensource'.
205207
nginx_type: opensource
208+
# Specify which version of NGINX you want to install.
209+
# Default is empty.
210+
# nginx_version: =19-1~bionic
206211

207212
# Specify repository origin for NGINX Open Source.
208213
# Options are 'nginx_repository' or 'os_repository'.
@@ -595,17 +600,19 @@ nginx_http_template:
595600

596601
# Enable NGINX status data.
597602
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
603+
# Note - 'status' has been deprecated since NGINX Plus R13.
598604
# Default is false.
599605
nginx_status_enable: false
600-
nginx_status_port: 8080
606+
nginx_status_location: /etc/nginx/conf.d/stub_status.conf
607+
nginx_status_port: 80
601608

602609
# Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
603610
# Requires NGINX Plus.
604611
# Default is false.
605612
nginx_rest_api_enable: false
606-
nginx_rest_api_src: http/api.conf.j2
607-
nginx_rest_api_location: /etc/nginx/conf.d/api.conf
608-
nginx_rest_api_port: 8080
613+
nginx_rest_api_template_file: http/api.conf.j2
614+
nginx_rest_api_file_location: /etc/nginx/conf.d/api.conf
615+
nginx_rest_api_port: 80
609616
nginx_rest_api_write: false
610617
nginx_rest_api_dashboard: false
611618

@@ -837,6 +844,7 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a
837844
vars:
838845
nginx_type: plus
839846
nginx_rest_api_enable: true
847+
nginx_rest_api_port: 80
840848
nginx_rest_api_write: true
841849
nginx_controller_enable: true
842850
nginx_controller_api_key: <API_KEY_HERE>

defaults/main.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,17 +409,19 @@ nginx_http_template:
409409

410410
# Enable NGINX status data.
411411
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
412+
# Note - 'status' has been deprecated since NGINX Plus R13.
412413
# Default is false.
413414
nginx_status_enable: false
414-
nginx_status_port: 8080
415+
nginx_status_location: /etc/nginx/conf.d/stub_status.conf
416+
nginx_status_port: 80
415417

416418
# Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
417419
# Requires NGINX Plus.
418420
# Default is false.
419421
nginx_rest_api_enable: false
420-
nginx_rest_api_src: http/api.conf.j2
421-
nginx_rest_api_location: /etc/nginx/conf.d/api.conf
422-
nginx_rest_api_port: 8080
422+
nginx_rest_api_template_file: http/api.conf.j2
423+
nginx_rest_api_file_location: /etc/nginx/conf.d/api.conf
424+
nginx_rest_api_port: 80
423425
nginx_rest_api_write: false
424426
nginx_rest_api_dashboard: false
425427

tasks/conf/setup-status.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
- name: "(Setup: NGINX Open Source) Enable NGINX Open Source Status"
33
blockinfile:
4-
path: "{{ (nginx_http_template_enable) | ternary('/etc/nginx/conf.d/http/stub_status.conf','/etc/nginx/conf.d/stub_status.conf') }}"
4+
path: "{{ nginx_status_location }}"
55
create: yes
66
block: |
77
server {
8-
listen 127.0.0.1:{{ nginx_status_port | default('8080') }};
8+
listen 127.0.0.1:{{ nginx_status_port | default('80') }};
99
location /nginx_status {
1010
stub_status on;
1111
allow 127.0.0.1;
@@ -17,11 +17,11 @@
1717

1818
- name: "(Setup: NGINX Plus) Enable NGINX Plus Status"
1919
blockinfile:
20-
path: "{{ (nginx_http_template_enable) | ternary('/etc/nginx/conf.d/http/status.conf','/etc/nginx/conf.d/status.conf') }}"
20+
path: "{{ nginx_status_location }}"
2121
create: yes
2222
block: |
2323
server {
24-
listen 127.0.0.1:{{ nginx_status_port | default('8080') }};
24+
listen 127.0.0.1:{{ nginx_status_port | default('80') }};
2525
location /status {
2626
status;
2727
allow 127.0.0.1;

tasks/conf/template-config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858

5959
- name: "(Setup: All NGINX) Dynamically Generate NGINX API Configuration File"
6060
template:
61-
src: "{{ nginx_rest_api_src | default('http/api.conf.j2') }}"
62-
dest: "{{ nginx_rest_api_location | default('/etc/nginx/conf.d/api.conf') }}"
61+
src: "{{ nginx_rest_api_template_file | default('http/api.conf.j2') }}"
62+
dest: "{{ nginx_rest_api_file_location | default('/etc/nginx/conf.d/api.conf') }}"
6363
backup: yes
6464
notify: "(Handler: All OSs) Reload NGINX"
6565
when: nginx_rest_api_enable | bool

templates/http/api.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{ ansible_managed | comment }}
22

33
server {
4-
listen {{ nginx_rest_api_port }};
4+
listen {{ nginx_rest_api_port | default('80') }};
55
location /api {
66
{% if nginx_rest_api_write %}
77
api write=on;

0 commit comments

Comments
 (0)