Merge pull request #109 from downingar/api_file
Changing the API config to be a template
This commit is contained in:
commit
1d30d42c68
@ -426,6 +426,7 @@ nginx_status_port: 8080
|
|||||||
# Requires NGINX Plus.
|
# Requires NGINX Plus.
|
||||||
# Default is false.
|
# Default is false.
|
||||||
nginx_rest_api_enable: false
|
nginx_rest_api_enable: false
|
||||||
|
nginx_rest_api_src: api.conf.j2
|
||||||
nginx_rest_api_location: /etc/nginx/conf.d/api.conf
|
nginx_rest_api_location: /etc/nginx/conf.d/api.conf
|
||||||
nginx_rest_api_port: 8080
|
nginx_rest_api_port: 8080
|
||||||
nginx_rest_api_write: false
|
nginx_rest_api_write: false
|
||||||
|
@ -265,6 +265,7 @@ nginx_status_port: 8080
|
|||||||
# Requires NGINX Plus.
|
# Requires NGINX Plus.
|
||||||
# Default is false.
|
# Default is false.
|
||||||
nginx_rest_api_enable: false
|
nginx_rest_api_enable: false
|
||||||
|
nginx_rest_api_src: api.conf.j2
|
||||||
nginx_rest_api_location: /etc/nginx/conf.d/api.conf
|
nginx_rest_api_location: /etc/nginx/conf.d/api.conf
|
||||||
nginx_rest_api_port: 8080
|
nginx_rest_api_port: 8080
|
||||||
nginx_rest_api_write: false
|
nginx_rest_api_write: false
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
- name: "(Setup: NGINX Plus) Setup NGINX Plus API"
|
|
||||||
blockinfile:
|
|
||||||
path: "{{ nginx_rest_api_location }}"
|
|
||||||
create: yes
|
|
||||||
block: |
|
|
||||||
server {
|
|
||||||
listen {{ nginx_rest_api_port }};
|
|
||||||
location /api {
|
|
||||||
{% if nginx_rest_api_write %}
|
|
||||||
api write=on;
|
|
||||||
{% else %}
|
|
||||||
api;
|
|
||||||
{% endif %}
|
|
||||||
}
|
|
||||||
{% if nginx_rest_api_dashboard %}
|
|
||||||
location = /dashboard.html {
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
}
|
|
||||||
{% endif %}
|
|
||||||
}
|
|
||||||
notify: "(Handler: All OSs) Reload NGINX"
|
|
@ -64,3 +64,11 @@
|
|||||||
with_dict: "{{ nginx_stream_template }}"
|
with_dict: "{{ nginx_stream_template }}"
|
||||||
when: nginx_stream_template_enable
|
when: nginx_stream_template_enable
|
||||||
notify: "(Handler: All OSs) Reload NGINX"
|
notify: "(Handler: All OSs) Reload NGINX"
|
||||||
|
|
||||||
|
- name: "(Setup: All NGINX) Dynamically Generate NGINX API Configuration File"
|
||||||
|
template:
|
||||||
|
src: "{{ nginx_rest_api_src }}"
|
||||||
|
dest: "{{ nginx_rest_api_location }}"
|
||||||
|
backup: yes
|
||||||
|
notify: "(Handler: All OSs) Reload NGINX"
|
||||||
|
when: nginx_rest_api_enable
|
||||||
|
@ -44,13 +44,11 @@
|
|||||||
when: nginx_main_template_enable
|
when: nginx_main_template_enable
|
||||||
or nginx_http_template_enable
|
or nginx_http_template_enable
|
||||||
or nginx_stream_template_enable
|
or nginx_stream_template_enable
|
||||||
|
or nginx_rest_api_enable
|
||||||
|
|
||||||
- import_tasks: conf/setup-status.yml
|
- import_tasks: conf/setup-status.yml
|
||||||
when: nginx_status_enable
|
when: nginx_status_enable
|
||||||
|
|
||||||
- import_tasks: conf/setup-rest-api.yml
|
|
||||||
when: nginx_rest_api_enable
|
|
||||||
|
|
||||||
- import_tasks: conf/debug-output.yml
|
- import_tasks: conf/debug-output.yml
|
||||||
when: nginx_debug_output
|
when: nginx_debug_output
|
||||||
|
|
||||||
|
17
templates/api.conf.j2
Normal file
17
templates/api.conf.j2
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{{ ansible_managed | comment }}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen {{ nginx_rest_api_port }};
|
||||||
|
location /api {
|
||||||
|
{% if nginx_rest_api_write %}
|
||||||
|
api write=on;
|
||||||
|
{% else %}
|
||||||
|
api;
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
{% if nginx_rest_api_dashboard %}
|
||||||
|
location = /dashboard.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user