Support __sshd_supports_validate

This commit is contained in:
Jakub Jelen 2022-09-26 16:33:28 +02:00
parent 1cf57fe318
commit c201ba2060
4 changed files with 14 additions and 3 deletions

View file

@ -103,6 +103,7 @@
changed_when: false changed_when: false
when: when:
- __sshd_hostkeys_from_config | from_json == [] - __sshd_hostkeys_from_config | from_json == []
- __sshd_supports_validate
- name: Generate temporary hostkey - name: Generate temporary hostkey
ansible.builtin.command: > ansible.builtin.command: >

View file

@ -16,7 +16,9 @@
group: "{{ sshd_config_group }}" group: "{{ sshd_config_group }}"
mode: "{{ sshd_config_mode }}" mode: "{{ sshd_config_mode }}"
validate: >- validate: >-
{% if sshd_test_hostkey is defined and sshd_test_hostkey.path is defined %} {% if not __sshd_supports_validate %}
true %s
{% elif sshd_test_hostkey is defined and sshd_test_hostkey.path is defined %}
{{ sshd_binary }} -t -f %s -h {{ sshd_test_hostkey.path }}/rsa_key {{ sshd_binary }} -t -f %s -h {{ sshd_test_hostkey.path }}/rsa_key
{% else %} {% else %}
{{ sshd_binary }} -t -f %s {{ sshd_binary }} -t -f %s
@ -33,7 +35,9 @@
group: "{{ sshd_config_group }}" group: "{{ sshd_config_group }}"
mode: "{{ sshd_config_mode }}" mode: "{{ sshd_config_mode }}"
validate: >- validate: >-
{% if sshd_test_hostkey is defined and sshd_test_hostkey.path is defined %} {% if not __sshd_supports_validate %}
true %s
{% elif sshd_test_hostkey is defined and sshd_test_hostkey.path is defined %}
{{ sshd_binary }} -t -f %s -h {{ sshd_test_hostkey.path }}/rsa_key {{ sshd_binary }} -t -f %s -h {{ sshd_test_hostkey.path }}/rsa_key
{% else %} {% else %}
{{ sshd_binary }} -t -f %s {{ sshd_binary }} -t -f %s

View file

@ -13,7 +13,9 @@
create: yes create: yes
marker: "# {mark} sshd system role managed block: namespace {{ sshd_config_namespace }}" marker: "# {mark} sshd system role managed block: namespace {{ sshd_config_namespace }}"
validate: >- validate: >-
{% if sshd_test_hostkey is defined and sshd_test_hostkey.path is defined %} {% if not __sshd_supports_validate %}
true %s
{% elif sshd_test_hostkey is defined and sshd_test_hostkey.path is defined %}
{{ sshd_binary }} -t -f %s -h {{ sshd_test_hostkey.path }}/rsa_key {{ sshd_binary }} -t -f %s -h {{ sshd_test_hostkey.path }}/rsa_key
{% else %} {% else %}
{{ sshd_binary }} -t -f %s {{ sshd_binary }} -t -f %s

View file

@ -47,3 +47,7 @@ __sshd_drop_in_dir_mode: '0755'
# This is usually the case when the selection is up to the OpenSSH defaults or # This is usually the case when the selection is up to the OpenSSH defaults or
# drop-in directory is used. # drop-in directory is used.
__sshd_verify_hostkeys_default: [] __sshd_verify_hostkeys_default: []
# This switch can control if the validate step is supported by the target OS.
# This is useful for very old OpenSSH or for tests that generate invalid configurations
__sshd_supports_validate: true