Major vhosts cleanup in preparation for issue #11.

pull/15/head
Jeff Geerling 9 years ago
parent c6e3321a66
commit 7360d9cb0b
  1. 7
      README.md
  2. 3
      defaults/main.yml
  3. 7
      tasks/main.yml
  4. 22
      tasks/vhosts.yml
  5. 1
      templates/vhosts.j2
  6. 2
      vars/Debian.yml
  7. 2
      vars/RedHat.yml

@ -14,10 +14,13 @@ None.
Available variables are listed below, along with default values (see `defaults/main.yml`):
nginx_vhost_path: /etc/nginx/sites-enabled
The path to the vhost configuration folder (where Nginx will look for server configurations).
nginx_remove_default_vhost: false
nginx_default_vhost_path: /etc/nginx/sites-enabled/default
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. The `nginx_default_vhost_path` variable defines the path to the default vhosts file.
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_user: "nginx"

@ -5,6 +5,7 @@ nginx_client_max_body_size: "64m"
nginx_keepalive_timeout: "65"
nginx_remove_default_vhost: false
nginx_default_vhost_path: /etc/nginx/sites-enabled/default
nginx_vhosts: []
# TODO - add example.
nginx_proxy_cache_path: ""

@ -28,9 +28,4 @@
- name: Ensure nginx is started and enabled to start at boot.
service: name=nginx state=started enabled=yes
- name: Remove default nginx config file (if configured).
file:
path: "{{ nginx_default_vhost_path }}"
state: absent
when: nginx_remove_default_vhost
notify: restart nginx
- include: vhosts.yml

@ -0,0 +1,22 @@
---
- name: Remove default nginx vhost config file (if configured).
file:
path: "{{ nginx_default_vhost_path }}"
state: absent
when: nginx_remove_default_vhost
notify: restart nginx
- name: Add managed vhost config file (if any vhosts are configured).
template:
src: vhosts.j2
dest: "{{ nginx_vhost_path }}/vhosts"
mode: 0644
when: nginx_vhosts
notify: restart nginx
- name: Remove managed vhost config file (if no vhosts are configured).
file:
path: "{{ nginx_vhost_path }}/vhosts"
state: absent
when: not nginx_vhosts
notify: restart nginx

@ -1,2 +1,4 @@
---
nginx_vhost_path: /etc/nginx/sites-enabled
nginx_default_vhost_path: /etc/nginx/sites-enabled/default
__nginx_user: "www-data"

@ -1,2 +1,4 @@
---
nginx_vhost_path: /etc/nginx/conf.d
nginx_default_vhost_path: /etc/nginx/conf.d/default.conf
__nginx_user: "nginx"