48 lines
2.0 KiB
YAML
48 lines
2.0 KiB
YAML
---
|
|
|
|
- name: Fail if redirect_target is a relative path and redirect_preserve_path is true
|
|
ansible.builtin.fail:
|
|
msg: redirect_target must be an absolute url or absolute path if redirect_preserve_path is true
|
|
when:
|
|
- redirect_preserve_path
|
|
- redirect_target.split('://') | length < 2
|
|
- not redirect_target.startswith('/')
|
|
|
|
- name: Fail if redirect_tartget ends with / and redirect_preserve_path is true
|
|
ansible.builtin.fail:
|
|
msg: redirect_target must not end with / if redirect_preserve_path is true
|
|
when:
|
|
- redirect_preserve_path
|
|
- redirect_target.endswith('/')
|
|
|
|
- name: Reset vhost_locations_all
|
|
ansible.builtin.set_fact:
|
|
vhost_locations_all: []
|
|
- name: Set vhost_locations_all reverse proxies
|
|
ansible.builtin.set_fact:
|
|
vhost_locations_all: >
|
|
{{ vhost_locations_all + [{
|
|
'path': item.path,
|
|
'type': item.type | default(vhost_type),
|
|
'headers': item.headers | default(vhost_headers),
|
|
|
|
'basicauth': item.basicauth | default(vhost_basicauth),
|
|
'basicauth_users': item.basicauth_users | default(vhost_basicauth_users),
|
|
|
|
'proxy_target_port': item.proxy_target_port | default(proxy_target_port if vhost_type == 'reverse_proxy' else ''),
|
|
'proxy_target_host': item.proxy_target_host | default(proxy_target_host),
|
|
'proxy_target_protocol': item.proxy_target_protocol | default(proxy_target_protocol),
|
|
|
|
'redirect_target': item.redirect_target | default(redirect_target if vhost_type == 'redirect' else ''),
|
|
'redirect_preserve_path': item.redirect_preserve_path | default(redirect_preserve_path),
|
|
'redirect_type': item.redirect_type | default(redirect_type),
|
|
|
|
'respond_content': item.respond_content | default(respond_content if vhost_type == 'respond' else ''),
|
|
'respond_content_type': item.respond_content_type | default(respond_content_type)
|
|
}] }}
|
|
loop: "{{ vhost_locations + [{'path': ''}] }}"
|
|
|
|
- name: "Setup {{ vhost_id + ' vhost on ' + web_server }}"
|
|
ansible.builtin.include_tasks: "{{ web_server }}.yml"
|
|
when: web_server != 'none'
|