Add optional vhost_filename option to nginx_vhosts

pull/105/head
Oskar Schöldström 7 years ago
parent 235a0053a7
commit 98b736f479
  1. 1
      README.md
  2. 1
      defaults/main.yml
  3. 4
      tasks/vhosts.yml

@ -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)(/.+)$;

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

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