Merge 41979991e5
into 57889e8ad6
commit
aa2f76114d
@ -0,0 +1,20 @@ |
|||||||
|
--- |
||||||
|
- name: Detect combined vhost filename |
||||||
|
set_fact: |
||||||
|
nginx_vhosts_filename: "{{ __nginx_vhosts_filename }}" |
||||||
|
when: nginx_vhosts_filename is not defined |
||||||
|
|
||||||
|
- name: Add managed vhost config file (if any vhosts are configured). |
||||||
|
template: |
||||||
|
src: vhosts.j2 |
||||||
|
dest: "{{ nginx_vhost_path }}/{{ nginx_vhosts_filename }}" |
||||||
|
mode: 0644 |
||||||
|
when: nginx_vhosts|length > 0 |
||||||
|
notify: reload nginx |
||||||
|
|
||||||
|
- name: Remove managed vhost config file (if no vhosts are configured). |
||||||
|
file: |
||||||
|
path: "{{ nginx_vhost_path }}/{{ nginx_vhosts_filename }}" |
||||||
|
state: absent |
||||||
|
when: nginx_vhosts|length == 0 |
||||||
|
notify: reload nginx |
@ -0,0 +1,26 @@ |
|||||||
|
--- |
||||||
|
- name: Add managed vhost config files. |
||||||
|
template: |
||||||
|
src: "{{ item.template|default(nginx_vhost_template) }}" |
||||||
|
dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" |
||||||
|
force: yes |
||||||
|
owner: root |
||||||
|
group: root |
||||||
|
mode: 0644 |
||||||
|
when: item.state|default('present') != 'absent' |
||||||
|
with_items: "{{ nginx_vhosts }}" |
||||||
|
notify: reload nginx |
||||||
|
|
||||||
|
- name: Remove managed vhost config files. |
||||||
|
file: |
||||||
|
path: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" |
||||||
|
state: absent |
||||||
|
when: item.state|default('present') == 'absent' |
||||||
|
with_items: "{{ nginx_vhosts }}" |
||||||
|
notify: reload nginx |
||||||
|
|
||||||
|
- name: Remove legacy vhosts.conf file. |
||||||
|
file: |
||||||
|
path: "{{ nginx_vhost_path }}/vhosts.conf" |
||||||
|
state: absent |
||||||
|
notify: reload nginx |
@ -0,0 +1,33 @@ |
|||||||
|
{% for vhost in nginx_vhosts %} |
||||||
|
server { |
||||||
|
listen {{ vhost.listen | default('80 default_server') }}; |
||||||
|
|
||||||
|
{% if vhost.server_name is defined %} |
||||||
|
server_name {{ vhost.server_name }}; |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
{% if vhost.root is defined %} |
||||||
|
root {{ vhost.root }}; |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
index {{ vhost.index | default('index.html index.htm') }}; |
||||||
|
|
||||||
|
{% if vhost.error_page is defined %} |
||||||
|
error_page {{ vhost.error_page }}; |
||||||
|
{% endif %} |
||||||
|
{% if vhost.access_log is defined %} |
||||||
|
access_log {{ vhost.access_log }}; |
||||||
|
{% endif %} |
||||||
|
{% if vhost.error_log is defined %} |
||||||
|
error_log {{ vhost.error_log }} error; |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
{% if vhost.return is defined %} |
||||||
|
return {{ vhost.return }}; |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
{% if vhost.extra_parameters is defined %} |
||||||
|
{{ vhost.extra_parameters|indent(4) }} |
||||||
|
{% endif %} |
||||||
|
} |
||||||
|
{% endfor %} |
Reference in new issue