diff --git a/README.md b/README.md index 46a6904..ac14222 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Socket: - `nginx_pid`: daemon pid file - `nginx_events_*`: all variables in events block - `nginx_http_*`: all variables in http block + - `nginx_custom_http`: instructions list (will put data in `/etc/nginx/conf.d/custom.conf`) ### Vhost management diff --git a/defaults/main.yml b/defaults/main.yml index 64a71c1..1e7843d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -73,6 +73,11 @@ nginx_http_gzip_types: 'text/plain text/css application/json application/x-javas nginx_http_gzip_vary: 'on' nginx_http_gzip_disable: '"msie6"' +# +# nginx_http_custom +# +nginx_http_custom: [] + # # Vhosts # diff --git a/tasks/main.yml b/tasks/main.yml index 766ea92..aa928f0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -36,6 +36,12 @@ with_fileglob: '../templates/etc/nginx/helper/*.j2' notify: reload nginx +- name: TEMPLATE | Deploy custom http configuration + template: > + src=etc/nginx/conf.d/custom.conf.j2 + dest=/etc/nginx/conf.d/custom.conf + notify: reload nginx + - name: INCLUDE | Upstream configuration include: upstream.yml when: nginx_php diff --git a/templates/etc/nginx/conf.d/custom.conf.j2 b/templates/etc/nginx/conf.d/custom.conf.j2 new file mode 100644 index 0000000..8bddc01 --- /dev/null +++ b/templates/etc/nginx/conf.d/custom.conf.j2 @@ -0,0 +1,7 @@ +# +# {{ ansible_managed }} +# + +{% for i in nginx_custom_http %} +{{ i }} +{% endfor %} diff --git a/tests/test.yml b/tests/test.yml index 7cfc6e2..e2026cd 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -28,6 +28,8 @@ description: 'Please login!' users: [] state: 'absent' + nginx_custom_http: + - 'add_header X-ansible 1;' nginx_vhosts: - name: - 'test.local'