From 736a95a012e8058c896c13b0e1e2a928fd5e314c Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Thu, 21 Aug 2014 15:41:31 -0500 Subject: [PATCH] Add option to remove default nginx vhost config. --- README.md | 7 ++++++- defaults/main.yml | 3 +++ tasks/main.yml | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 defaults/main.yml diff --git a/README.md b/README.md index c94af6f..5ba9ece 100644 --- a/README.md +++ b/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" diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..7543516 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,3 @@ +--- +nginx_remove_default_vhost: false +nginx_default_vhost_path: /etc/nginx/sites-enabled/default diff --git a/tasks/main.yml b/tasks/main.yml index fe3ef2d..5491d0b 100644 --- a/tasks/main.yml +++ b/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 \ No newline at end of file