From c4ee6eb1a293b4c5359a0f78b8abf98b9f6b25e4 Mon Sep 17 00:00:00 2001 From: Emilien Mantel Date: Fri, 7 Oct 2016 10:50:05 +0200 Subject: [PATCH] vhost.filename used by log and directories creation --- tasks/vhost.yml | 2 +- templates/etc/nginx/sites-available/_base.j2 | 2 +- tests/test.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tasks/vhost.yml b/tasks/vhost.yml index 8f57197..4c4e5ee 100644 --- a/tasks/vhost.yml +++ b/tasks/vhost.yml @@ -27,7 +27,7 @@ - name: FILE | Create root public folders (foreach nginx_vhosts) file: > - path={{ nginx_root }}/{{ item.name if item.name is string else item.name[0] }}/public + path={{ nginx_root }}/{{ item.filename | default(item.name if item.name is string else item.name[0]) }}/public state=directory owner={{ item.owner | default(nginx_user) }} group={{ item.group | default(nginx_user) }} diff --git a/templates/etc/nginx/sites-available/_base.j2 b/templates/etc/nginx/sites-available/_base.j2 index c30adcd..a950206 100644 --- a/templates/etc/nginx/sites-available/_base.j2 +++ b/templates/etc/nginx/sites-available/_base.j2 @@ -1,5 +1,5 @@ {% set __proto = item.proto | default(['http']) %} -{% set __main_name = item.name if item.name is string else item.name[0] %} +{% set __main_name = item.filename | default(item.name if item.name is string else item.name[0]) %} {% set __listen = item.listen | default(['80']) %} {% set __listen_ssl = item.listen_ssl | default(['443']) %} {% set __location = item.location | default({}) %} diff --git a/tests/test.yml b/tests/test.yml index a5d198a..65c2a56 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -106,7 +106,7 @@ -----END CERTIFICATE----- nginx_custom_http: - 'add_header X-ansible 1;' - nginx_default_vhost: 'test.local' + nginx_default_vhost: 'first-test' nginx_default_vhost_ssl: 'test-ssl-predeployed.local' nginx_vhosts: - name: @@ -120,7 +120,7 @@ 'X-Frame-Options': 'deny always' 'X-ansible-default': '1' manage_local_content: false - use_error_log: false + use_error_log: true more: - 'autoindex off;' location: @@ -209,7 +209,7 @@ with_items: ['test-php.local', 'test-php-index.local'] - name: -- Add HTML file -- copy: dest="{{ item }}/index.html" content="Index HTML test OK\n" - with_items: ['{{ nginx_root }}/test.local/public', '/var/tmp', '{{ nginx_root }}/test-htpasswd-all.local/public', '{{ nginx_root }}/test-ssl.local/public', '{{ nginx_root }}/test-ssl-predeployed.local/public'] + with_items: ['{{ nginx_root }}/first-test/public', '/var/tmp', '{{ nginx_root }}/test-htpasswd-all.local/public', '{{ nginx_root }}/test-ssl.local/public', '{{ nginx_root }}/test-ssl-predeployed.local/public'] - name: -- Create directory -- file: path={{ nginx_root }}/test-htpasswd.local/public/hello state=directory - name: -- Add HTML file hello --