diff --git a/README.md b/README.md index 7c18ed7..fd29db5 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ A list of vhost definitions (server blocks) for Nginx virtual hosts. Each entry error_log: "" state: "present" template: "{{ nginx_vhost_template }}" + vhost_filename: "example.com.conf" extra_parameters: | location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; diff --git a/defaults/main.yml b/defaults/main.yml index 9851f06..a7a4db4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -60,6 +60,7 @@ nginx_vhosts: [] # server_name_redirect: "www.example.com" # default: N/A # root: "/var/www/example.com" # default: N/A # index: "index.html index.htm" # default: "index.html index.htm" +# vhost_filename: "example.com.conf" # Can be used to set the filename of the vhost file. # # # Properties that are only added if defined: # error_page: "" diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index 03c32d9..e7bd642 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -15,7 +15,7 @@ - name: Add managed vhost config files. template: src: "{{ item.template|default(nginx_vhost_template) }}" - dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" + dest: "{{ nginx_vhost_path }}/{{ item.vhost_filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" force: yes owner: root group: root @@ -26,7 +26,7 @@ - name: Remove managed vhost config files. file: - path: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" + path: "{{ nginx_vhost_path }}/{{ item.vhost_filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" state: absent when: item.state|default('present') == 'absent' with_items: "{{ nginx_vhosts }}"