diff --git a/defaults/main.yml b/defaults/main.yml index 6c40e1e..2f9208a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,4 +1,7 @@ --- +# enable option if know that your ssh-server version is over 8.0 +# sshd__version_is_above_eight: true + # set the ssh server port sshd__port: 22 # ssh password authorisatuin (not recomended) diff --git a/tasks/main.yml b/tasks/main.yml index dcb6bbc..f4e00e8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -22,16 +22,24 @@ sshd__allowed_users: '{{ sshd__allowed_users + users.keys() | default({}) | sort }}' sshd__allowed_groups: '{{ sshd__allowed_groups + users.keys() | default({}) | sort }}' -- name: "get package version of {{ sshd__package }}" - debug: - msg: "{{ ansible_facts.packages[sshd__package][0].version }}" - when: sshd__package in ansible_facts.packages - failed_when: false +- name: "try to get {{ sshd__package }} version" + when: sshd__version_is_above_eight is not defined + block: + - name: Gather the package facts + package_facts: + manager: auto -- name: set fact sshd__version_is_above_eight - set_fact: - sshd__version_is_above_eight: true - when: ansible_facts.packages[sshd__package][0].version is version('8.0', '>=') + - name: "get package version of {{ sshd__package }}" + debug: + msg: "{{ ansible_facts.packages[sshd__package][0].version }}" + + - name: set fact sshd__version_is_above_eight + set_fact: + sshd__version_is_above_eight: true + when: ansible_facts.packages[sshd__package][0].version is version('8.0', '>=') + rescue: + - debug: + msg: "Failed to detect ssh version. Set sshd__version_is_above_eight to true if you want to experience new config features from sshd version 8" - include_tasks: keys.yml diff --git a/vars/main.yml b/vars/main.yml index 543fb66..7a5eb74 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,3 @@ --- -playbook_version_number: 4097 # should be over ninethousand +playbook_version_number: 4098 # should be over ninethousand playbook_version_path: 'role-sshd_chaos-bodensee_github.com.version'