Compare commits

...

3 Commits

Author SHA1 Message Date
uumas
1d5918bc6d compatcheck: Use new ansible facts syntax 2026-08-02 00:10:59 +03:00
uumas
1afc3338b1 ssh: Ensure ssh enabled, use ssh.service unit on debian 2026-08-02 00:10:15 +03:00
uumas
a1e6c03827 vhost: Add support for matching by query 2026-03-28 05:58:51 +02:00
9 changed files with 61 additions and 10 deletions

View File

@@ -4,10 +4,10 @@
msg: "{{ lookup('ansible.builtin.template', 'distroerror.j2').strip() }}" msg: "{{ lookup('ansible.builtin.template', 'distroerror.j2').strip() }}"
when: > when: >
_compatcheck_distro | length != 1 or ( _compatcheck_distro | length != 1 or (
ansible_distribution_major_version != 'n/a' and ansible_facts.distribution_major_version != 'n/a' and
_compatcheck_distro[0].version_min | default(0) > ansible_distribution_major_version | int _compatcheck_distro[0].version_min | default(0) > ansible_facts.distribution_major_version | int
) or ) or
_compatcheck_distro[0].version_max is defined and _compatcheck_distro[0].version_max < ansible_distribution_major_version | int or _compatcheck_distro[0].version_max is defined and _compatcheck_distro[0].version_max < ansible_facts.distribution_major_version | int or
ansible_pkg_mgr not in _compatcheck_distro[0].package_managers | default([_compatcheck_default_package_manager]) ansible_facts.pkg_mgr not in _compatcheck_distro[0].package_managers | default([_compatcheck_default_package_manager])
loop_control: loop_control:
loop_var: checkfailed loop_var: checkfailed

View File

@@ -15,4 +15,4 @@
{{ distros.append(distro_name ~ distro_package_managers_str) }} {{ distros.append(distro_name ~ distro_package_managers_str) }}
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
This role only supports {{ distros | join(', ') }} (You are running {{ ansible_distribution }} {{ ansible_distribution_major_version }} ({{ ansible_pkg_mgr }}) This role only supports {{ distros | join(', ') }} (You are running {{ ansible_facts.distribution }} {{ ansible_facts.distribution_major_version }} ({{ ansible_facts.pkg_mgr }})

View File

@@ -1,9 +1,9 @@
--- ---
_compatcheck_distro: "{{ compatcheck_supported_distributions | selectattr('name', 'equalto', ansible_distribution | lower) }}" _compatcheck_distro: "{{ compatcheck_supported_distributions | selectattr('name', 'equalto', ansible_facts.distribution | lower) }}"
_compatcheck_default_package_managers: _compatcheck_default_package_managers:
debian: apt debian: apt
ubuntu: apt ubuntu: apt
fedora: dnf fedora: dnf
archlinux: pacman archlinux: pacman
macosx: homebrew macosx: homebrew
_compatcheck_default_package_manager: "{{ _compatcheck_default_package_managers[ansible_distribution | lower] }}" _compatcheck_default_package_manager: "{{ _compatcheck_default_package_managers[ansible_facts.distribution | lower] }}"

View File

@@ -1,5 +1,5 @@
--- ---
- name: Restart sshd - name: Restart ssh service
ansible.builtin.systemd_service: ansible.builtin.systemd_service:
name: sshd.service name: "{{ _ssh_service_name }}"
state: restarted state: restarted

View File

@@ -6,8 +6,13 @@
line: "{{ item.key }} {{ item.value }}" line: "{{ item.key }} {{ item.value }}"
state: present state: present
validate: '/usr/sbin/sshd -t -f %s' validate: '/usr/sbin/sshd -t -f %s'
notify: Restart sshd notify: Restart ssh service
with_dict: with_dict:
PermitRootLogin: "prohibit-password" PermitRootLogin: "prohibit-password"
PasswordAuthentication: "{{ 'yes' if ssh_password_auth else 'no' }}" PasswordAuthentication: "{{ 'yes' if ssh_password_auth else 'no' }}"
X11Forwarding: "no" X11Forwarding: "no"
- name: Ensure ssh service is enabled
ansible.builtin.systemd_service:
name: "{{ _ssh_service_name }}"
enabled: true

2
roles/ssh/vars/main.yaml Normal file
View File

@@ -0,0 +1,2 @@
---
_ssh_service_name: "{{ 'ssh.service' if ansible_facts.os_family == 'Debian' else 'sshd.service' }}"

View File

@@ -247,6 +247,26 @@ argument_specs:
type: dict type: dict
required: false required: false
default: {} default: {}
match_query:
description: Query to match
type: list
elements: dict
required: false
default: []
options:
key:
description: Query key to match
type: str
required: true
value:
description: Query value to match. Matches any if unset.
type: str
required: false
reverse:
description: If true, matches request without matching key/value
type: bool
required: false
default: false
type: type:
type: str type: str
@@ -655,6 +675,26 @@ argument_specs:
type: dict type: dict
required: false required: false
default: {} default: {}
match_query:
description: Query to match
type: list
elements: dict
required: false
default: []
options:
key:
description: Query key to match
type: str
required: true
value:
description: Query value to match. Matches any if unset.
type: str
required: false
reverse:
description: If true, matches request without matching key/value
type: bool
required: false
default: false
type: type:
type: str type: str

View File

@@ -10,6 +10,9 @@
{% for matcher in location.matchers %} {% for matcher in location.matchers %}
{% if matcher.name != '' %} {% if matcher.name != '' %}
@{{ matcher.name }} { @{{ matcher.name }} {
{% for query in matcher.match_query | default([]) %}
{{ 'not ' if query.reverse else '' }}query {{ query.key }}={{ query.value | default('*') }}
{% endfor %}
{% if matcher.match_methods | default([]) | length > 0 %} {% if matcher.match_methods | default([]) | length > 0 %}
method {{ matcher.match_methods | join(' ') }} method {{ matcher.match_methods | join(' ') }}
{% endif %} {% endif %}

View File

@@ -2,6 +2,7 @@
_vhost_matcher_defaults: _vhost_matcher_defaults:
match_headers: {} match_headers: {}
match_methods: [] match_methods: []
match_query: []
_vhost_matchers: >- _vhost_matchers: >-
{{ {{
vhost_matchers vhost_matchers