Add a vhost role
This commit is contained in:
25
roles/vhost/tasks/caddy.yml
Normal file
25
roles/vhost/tasks/caddy.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
|
||||
- name: Add caddy vhost config
|
||||
blockinfile:
|
||||
path: /etc/caddy/Caddyfile
|
||||
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ vhost_id }}"
|
||||
block: |
|
||||
{{ vhost_domains | join(' ') }} {
|
||||
{% if vhost_type == 'reverse_proxy' %}
|
||||
reverse_proxy {{ proxy_target_protocol }}://{{ proxy_target_host }}:{{ proxy_target_port }} {
|
||||
{% if proxy_target_protocol == 'https' and proxy_target_host == 'localhost' %}
|
||||
transport http {
|
||||
tls_insecure_skip_verify
|
||||
}
|
||||
{% endif %}
|
||||
}
|
||||
{% endif %}
|
||||
{% if vhost_type == 'redirect' %}
|
||||
redir {{ redirect_target }} {{ redirect_type }}
|
||||
{% endif %}
|
||||
}
|
||||
validate: 'caddy validate --config %s --adapter caddyfile'
|
||||
backup: true
|
||||
notify: reload caddy
|
||||
|
||||
Reference in New Issue
Block a user