vhost: lint

This commit is contained in:
uumas
2024-11-05 15:48:03 +02:00
parent 05714898eb
commit 20c24f2f1b
2 changed files with 10 additions and 6 deletions

View File

@@ -20,16 +20,18 @@ argument_specs:
- present - present
- absent - absent
vhost_type: vhost_type:
description: Required if vhost_state is present
type: str type: str
required: "{{ vhost_state == 'present' }}" required: false
choices: choices:
- reverse_proxy - reverse_proxy
- redirect - redirect
- respond - respond
- absent - absent
vhost_domains: vhost_domains:
description: Required if vhost_state is present
type: list type: list
required: "{{ vhost_state == 'present' }}" required: false
elements: str elements: str
vhost_web_server: vhost_web_server:
description: Defines which server software to use for vhost. This role does nothing if set to none. description: Defines which server software to use for vhost. This role does nothing if set to none.
@@ -94,13 +96,13 @@ argument_specs:
- Port where to proxy requests to. - Port where to proxy requests to.
- Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is tcp. - Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is tcp.
type: int type: int
required: "{{ vhost_state == 'present' and vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'tcp' }}" required: false
vhost_proxy_target_socket: vhost_proxy_target_socket:
description: description:
- Unix socket path to proxy requests to. - Unix socket path to proxy requests to.
- Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is unix. - Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is unix.
type: str type: str
required: "{{ vhost_state == 'present' and vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'unix' }}" required: false
vhost_proxy_delete_headers: vhost_proxy_delete_headers:
description: List of headers to delete from proxied requests description: List of headers to delete from proxied requests
type: list type: list
@@ -111,7 +113,7 @@ argument_specs:
vhost_redirect_target: vhost_redirect_target:
description: "Only applicable if vhost_type is redirect. Example: https://www.domain.tld/location" description: "Only applicable if vhost_type is redirect. Example: https://www.domain.tld/location"
type: str type: str
required: "{{ vhost_state == 'present' and vhost_type == 'redirect' }}" required: false
vhost_redirect_preserve_path: vhost_redirect_preserve_path:
description: Whether to keep the original request path description: Whether to keep the original request path
type: bool type: bool
@@ -134,7 +136,7 @@ argument_specs:
vhost_respond_content: vhost_respond_content:
description: Content to respond with. Json content can be set as yaml as long as vhost_respond_content_type is set to json description: Content to respond with. Json content can be set as yaml as long as vhost_respond_content_type is set to json
type: str type: str
required: "{{ vhost_state == 'present' and vhost_type == 'respond' }}" required: false
vhost_respond_content_type: vhost_respond_content_type:
description: Type of the respond content description: Type of the respond content
type: str type: str

View File

@@ -4,6 +4,7 @@
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
path: /etc/caddy/Caddyfile path: /etc/caddy/Caddyfile
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ vhost_id }}" marker: "# {mark} ANSIBLE MANAGED BLOCK {{ vhost_id }}"
# yamllint disable rule:line-length
block: | block: |
{{ vhost_domains | join(' ') }} { {{ vhost_domains | join(' ') }} {
{% for location in vhost_locations_all %} {% for location in vhost_locations_all %}
@@ -52,6 +53,7 @@
} }
{% endfor %} {% endfor %}
} }
# yamllint enable rule:line-length
validate: 'caddy validate --config %s --adapter caddyfile' validate: 'caddy validate --config %s --adapter caddyfile'
backup: true backup: true
state: "{{ vhost_state }}" state: "{{ vhost_state }}"