diff --git a/defaults/main.yml b/defaults/main.yml index 168aaf0..355865e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -31,14 +31,11 @@ amplify_key: null # Default is false. status_enable: false -# Enable NGINX Plus REST API and write access. +# Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard. # Default is false. rest_api_enable: false rest_api_write: false - -# Enable NGINX Plus dashboard. REST API also needs to be enabled. -# Default is false. -dashboard: false +rest_api_dashboard: false # Location of your NGINX Plus license in your local machine. # Default is the files folder within the NGINX Ansible role. @@ -63,8 +60,8 @@ main_template_user: nginx main_template_worker_processes: auto main_template_error_level: warn main_template_worker_connections: 1024 -main_template_keepalive_timeout: 65 http_template_enable: false +http_template_keepalive_timeout: 65 http_template_listen: 80 http_template_server_name: localhost stream_template_enable: false diff --git a/tasks/conf/setup-rest-api.yml b/tasks/conf/setup-rest-api.yml index d49e1e2..67abbba 100644 --- a/tasks/conf/setup-rest-api.yml +++ b/tasks/conf/setup-rest-api.yml @@ -1,6 +1,22 @@ --- - name: "(Setup: NGINX Plus) Setup NGINX Plus API" - template: - src: api.conf.j2 - dest: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/api.conf','/etc/nginx/conf.d/api.conf') }}" + blockinfile: + path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/api.conf','/etc/nginx/conf.d/api.conf') }}" + create: yes + block: | + server { + listen 8080; + location /api { + {% if rest_api_write %} + api write=on; + {% else %} + api; + {% endif %} + } + {% if rest_api_dashboard %} + location = /dashboard.html { + root /usr/share/nginx/html; + } + {% endif %} + } notify: "(Handler: All OSs) Reload NGINX" diff --git a/templates/http/api.conf.j2 b/templates/http/api.conf.j2 deleted file mode 100644 index 9b72fe6..0000000 --- a/templates/http/api.conf.j2 +++ /dev/null @@ -1,17 +0,0 @@ -{% if rest_api_enable %} -server { - listen 8080; - location /api { -{% if rest_api_write %} - api write=on; -{% else %} - api; -{% endif %} - } -{% if dashboard %} - location = /dashboard.html { - root /usr/share/nginx/html; - } -{% endif %} -} -{% endif %} diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index 5a60037..153696e 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -23,7 +23,7 @@ http { sendfile on; #tcp_nopush on; - keepalive_timeout {{ main_template_keepalive_timeout }}; + keepalive_timeout {{ http_template_keepalive_timeout }}; #gzip on;