Explorar el Código

Add option to remove default nginx vhost config.

Jeff Geerling hace 11 años
padre
commit
736a95a012
Se han modificado 3 ficheros con 16 adiciones y 1 borrados
  1. 6 1
      README.md
  2. 3 0
      defaults/main.yml
  3. 7 0
      tasks/main.yml

+ 6 - 1
README.md

@@ -12,7 +12,12 @@ None.
 
 ## Role Variables
 
-Available variables are listed below, along with default values (see `vars/main.yml`):
+Available variables are listed below, along with default values (see `vars/main.yml` and `defaults/main.yml`):
+
+    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.
 
     nginx_user: "nginx"
 

+ 3 - 0
defaults/main.yml

@@ -0,0 +1,3 @@
+---
+nginx_remove_default_vhost: false
+nginx_default_vhost_path: /etc/nginx/sites-enabled/default

+ 7 - 0
tasks/main.yml

@@ -23,3 +23,10 @@
 
 - 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