From de0b7de0ba1413e8d0dfdd410defbbeaf1998fd6 Mon Sep 17 00:00:00 2001 From: L3D Date: Mon, 21 Sep 2020 14:51:37 +0200 Subject: [PATCH] update sshd version eight detection --- defaults/main.yml | 3 +++ tasks/main.yml | 26 +++++++++++++++++--------- vars/main.yml | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) 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'