From 20c24f2f1b19c55b54abd55ba088b1cd6323d826 Mon Sep 17 00:00:00 2001 From: uumas Date: Tue, 5 Nov 2024 15:48:03 +0200 Subject: [PATCH] vhost: lint --- roles/vhost/meta/argument_specs.yaml | 14 ++++++++------ roles/vhost/tasks/caddy.yaml | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/roles/vhost/meta/argument_specs.yaml b/roles/vhost/meta/argument_specs.yaml index 533a5b6..c0713ab 100644 --- a/roles/vhost/meta/argument_specs.yaml +++ b/roles/vhost/meta/argument_specs.yaml @@ -20,16 +20,18 @@ argument_specs: - present - absent vhost_type: + description: Required if vhost_state is present type: str - required: "{{ vhost_state == 'present' }}" + required: false choices: - reverse_proxy - redirect - respond - absent vhost_domains: + description: Required if vhost_state is present type: list - required: "{{ vhost_state == 'present' }}" + required: false elements: str vhost_web_server: 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. - Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is tcp. type: int - required: "{{ vhost_state == 'present' and vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'tcp' }}" + required: false vhost_proxy_target_socket: description: - Unix socket path to proxy requests to. - Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is unix. type: str - required: "{{ vhost_state == 'present' and vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'unix' }}" + required: false vhost_proxy_delete_headers: description: List of headers to delete from proxied requests type: list @@ -111,7 +113,7 @@ argument_specs: vhost_redirect_target: description: "Only applicable if vhost_type is redirect. Example: https://www.domain.tld/location" type: str - required: "{{ vhost_state == 'present' and vhost_type == 'redirect' }}" + required: false vhost_redirect_preserve_path: description: Whether to keep the original request path type: bool @@ -134,7 +136,7 @@ argument_specs: 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 type: str - required: "{{ vhost_state == 'present' and vhost_type == 'respond' }}" + required: false vhost_respond_content_type: description: Type of the respond content type: str diff --git a/roles/vhost/tasks/caddy.yaml b/roles/vhost/tasks/caddy.yaml index 9f756d5..45d269b 100644 --- a/roles/vhost/tasks/caddy.yaml +++ b/roles/vhost/tasks/caddy.yaml @@ -4,6 +4,7 @@ ansible.builtin.blockinfile: path: /etc/caddy/Caddyfile marker: "# {mark} ANSIBLE MANAGED BLOCK {{ vhost_id }}" + # yamllint disable rule:line-length block: | {{ vhost_domains | join(' ') }} { {% for location in vhost_locations_all %} @@ -52,6 +53,7 @@ } {% endfor %} } + # yamllint enable rule:line-length validate: 'caddy validate --config %s --adapter caddyfile' backup: true state: "{{ vhost_state }}"