From b776ce7dee2aad8b6c59c1d3d7a375cdbf26a5f5 Mon Sep 17 00:00:00 2001 From: Lorenzo Gaggini Date: Sat, 15 Sep 2018 10:19:04 +0200 Subject: [PATCH] option to creare vhosts root directory --- README.md | 4 ++++ defaults/main.yml | 1 + tasks/main.yml | 1 + tasks/vhosts_root.yml | 12 ++++++++++++ 4 files changed, 18 insertions(+) create mode 100644 tasks/vhosts_root.yml diff --git a/README.md b/README.md index ef8c7cc..fbd4287 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,10 @@ An example of a secondary vhost which will redirect to the one shown above. Whether to remove the 'default' virtualhost configuration supplied by Nginx. Useful if you want the base `/` URL to be directed at one of your own virtual hosts configured in a separate .conf file. + nginx_vhosts_root_create: false + +Whether to create the root folder for the vhosts specified in the `nginx_vhosts` variable. The ownership of the folder is specified by the `nginx_user` variable, permission are 0744. + nginx_upstreams: [] If you are configuring Nginx as a load balancer, you can define one or more upstream sets using this variable. In addition to defining at least one upstream, you would need to configure one of your server blocks to proxy requests through the defined upstream (e.g. `proxy_pass http://myapp1;`). See the commented example in `defaults/main.yml` for more information. diff --git a/defaults/main.yml b/defaults/main.yml index 73100c5..990fde4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -69,6 +69,7 @@ nginx_vhosts: [] # extra_parameters: "" # Can be used to add extra config blocks (multiline). # template: "" # Can be used to override the `nginx_vhost_template` per host. # state: "absent" # To remove the vhost configuration. +nginx_vhosts_root_create: false nginx_upstreams: [] # - name: myapp1 diff --git a/tasks/main.yml b/tasks/main.yml index fd523d9..93e8b11 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -29,6 +29,7 @@ # Vhost configuration. - import_tasks: vhosts.yml +- import_tasks: vhosts_root.yml # Nginx setup. - name: Copy nginx configuration in place. diff --git a/tasks/vhosts_root.yml b/tasks/vhosts_root.yml new file mode 100644 index 0000000..8b1556e --- /dev/null +++ b/tasks/vhosts_root.yml @@ -0,0 +1,12 @@ +--- +- name: Ensure managed vhost root directory are present + file: + path: "{{ item.root }}" + state: directory + owner: "{{ nginx_user }}" + group: "{{ nginx_user }}" + mode: 0755 + when: + - item.root is defined + - nginx_vhosts_root_create + with_items: "{{ nginx_vhosts }}"