vhost: Add support for custom matchers and specifying response status

This commit is contained in:
uumas
2025-07-05 15:38:17 +03:00
parent 3cd66c54a7
commit 6c340c5111
4 changed files with 429 additions and 49 deletions

View File

@@ -1,4 +1,15 @@
---
_vhost_matcher_defaults:
match_headers: {}
match_method: []
_vhost_matchers: >-
{{
vhost_matchers
| map('combine', _vhost_matcher_defaults)
| zip(vhost_matchers)
| map('combine')
}}
_vhost_location_defaults:
type: "{{ vhost_type }}"
headers: "{{ vhost_headers }}"
@@ -25,12 +36,36 @@ _vhost_location_defaults:
respond_content: "{{ vhost_respond_content if vhost_type == 'respond' else '' }}"
respond_content_type: "{{ vhost_respond_content_type }}"
respond_status: "{{ vhost_respond_status }}"
matchers: "{{ _vhost_matchers }}"
_vhost_locations: "{{ vhost_locations + [{'path': ''}] }}"
_vhost_locations_complete: "{{
_vhost_locations
| map('combine', _vhost_location_defaults)
| zip(_vhost_locations)
| map('combine')
}}"
_vhost_locations_withdefaults: >-
{{
_vhost_locations
| map('combine', _vhost_location_defaults)
| zip(
_vhost_locations
)
| map('combine')
| map('combine', {'matchers': [{'name': ''}]}, list_merge='append')
}}
_vhost_locations_complete: >-
{{
_vhost_locations_withdefaults |
sort(attribute='path') |
zip(
_vhost_locations_withdefaults |
subelements('matchers') |
map('combine') |
groupby('path') |
map('last') |
map('community.general.remove_keys', ['matchers', 'path']) |
map('community.general.dict_kv', 'matchers')
) |
map('combine') |
reverse
}}