Files
ansible-general/roles/vhost/tasks/main.yml

45 lines
1.8 KiB
YAML

---
- name: Fail if redirect_target is a relative path and redirect_preserve_path is true
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
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
set_fact:
vhost_locations_all: []
- name: Set vhost_locations_all reverse proxies
set_fact:
vhost_locations_all: >
{{ vhost_locations_all + [{
'path': item.path,
'type': item.type | default(vhost_type),
'headers': item.headers | default(vhost_headers),
'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 }}"
include_tasks: "{{ web_server }}.yml"
when: web_server != 'none'