diff --git a/README.md b/README.md index 19fc4bf..d92b7a0 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ You can see many examples in: [tests/test.yml](tests/test.yml). #### Common - `name`: (M) Domain or list of domain used. - - `template`: (M) template used to create vhost + - `template`: (M) template used to create vhost. Optional if you set `delete` to true. - `enable`: (O) Enable the vhost (default is true) - `delete`: (O) Delete the vhost (default is false) - `redirect_from`: (O) Domain list to redirect to the first `name`. You can use this key to redirect non-www to www diff --git a/tasks/vhost.yml b/tasks/vhost.yml index 46188a4..4d494fa 100644 --- a/tasks/vhost.yml +++ b/tasks/vhost.yml @@ -13,7 +13,10 @@ group={{ item.group | default('www-data') }} mode={{ item.mode | default('0755') }} with_items: nginx_vhosts - when: item.root is not defined and item.template != '_proxy' + when: > + item.root is not defined and + (item.template is defined and item.template != '_proxy') and + (item.delete is not defined or not item.delete) - name: FILE | Create root public folders (foreach nginx_vhosts) file: > @@ -23,7 +26,10 @@ group={{ item.group | default('www-data') }} mode={{ item.mode | default('0755') }} with_items: nginx_vhosts - when: item.root is not defined and item.template != '_proxy' + when: > + item.root is not defined and + (item.template is defined and item.template != '_proxy') and + (item.delete is not defined or not item.delete) - name: TEMPLATE | Create vhosts template: > diff --git a/tests/test.yml b/tests/test.yml index de70fd6..6afe39e 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -49,7 +49,6 @@ template: '_proxy' upstream_name: 'test' - name: 'deleted.local' - template: '_base' delete: true roles: - ../../