Skip to content

Commit 6f05bc4

Browse files
authored
Merge pull request #18 from nginxinc/(feature)/refactor-rest-api
Refactor REST API deployment
2 parents 4fa9a51 + 6047a11 commit 6f05bc4

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

defaults/main.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,11 @@ amplify_key: null
3131
# Default is false.
3232
status_enable: false
3333

34-
# Enable NGINX Plus REST API and write access.
34+
# Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
3535
# Default is false.
3636
rest_api_enable: false
3737
rest_api_write: false
38-
39-
# Enable NGINX Plus dashboard. REST API also needs to be enabled.
40-
# Default is false.
41-
dashboard: false
38+
rest_api_dashboard: false
4239

4340
# Location of your NGINX Plus license in your local machine.
4441
# Default is the files folder within the NGINX Ansible role.
@@ -63,8 +60,8 @@ main_template_user: nginx
6360
main_template_worker_processes: auto
6461
main_template_error_level: warn
6562
main_template_worker_connections: 1024
66-
main_template_keepalive_timeout: 65
6763
http_template_enable: false
64+
http_template_keepalive_timeout: 65
6865
http_template_listen: 80
6966
http_template_server_name: localhost
7067
stream_template_enable: false

tasks/conf/setup-rest-api.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
---
22
- name: "(Setup: NGINX Plus) Setup NGINX Plus API"
3-
template:
4-
src: api.conf.j2
5-
dest: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/api.conf','/etc/nginx/conf.d/api.conf') }}"
3+
blockinfile:
4+
path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/api.conf','/etc/nginx/conf.d/api.conf') }}"
5+
create: yes
6+
block: |
7+
server {
8+
listen 8080;
9+
location /api {
10+
{% if rest_api_write %}
11+
api write=on;
12+
{% else %}
13+
api;
14+
{% endif %}
15+
}
16+
{% if rest_api_dashboard %}
17+
location = /dashboard.html {
18+
root /usr/share/nginx/html;
19+
}
20+
{% endif %}
21+
}
622
notify: "(Handler: All OSs) Reload NGINX"

templates/http/api.conf.j2

Lines changed: 0 additions & 17 deletions
This file was deleted.

templates/nginx.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ http {
2323
sendfile on;
2424
#tcp_nopush on;
2525

26-
keepalive_timeout {{ main_template_keepalive_timeout }};
26+
keepalive_timeout {{ http_template_keepalive_timeout }};
2727

2828
#gzip on;
2929

0 commit comments

Comments
 (0)