option to creare vhosts root directory

pull/170/head
Lorenzo Gaggini 6 years ago
parent 57ef9e3855
commit b776ce7dee
  1. 4
      README.md
  2. 1
      defaults/main.yml
  3. 1
      tasks/main.yml
  4. 12
      tasks/vhosts_root.yml

@ -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.

@ -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

@ -29,6 +29,7 @@
# Vhost configuration.
- import_tasks: vhosts.yml
- import_tasks: vhosts_root.yml
# Nginx setup.
- name: Copy nginx configuration in place.

@ -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 }}"