From 61bcf5fb59a55f0f896e86018b6fdb7e7ce2605f Mon Sep 17 00:00:00 2001 From: L3D Date: Fri, 16 Nov 2018 11:44:36 +0100 Subject: [PATCH] On Fedora it is sshd --- handlers/main.yml | 2 +- tasks/main.yml | 15 +++++++++++++-- vars/Fedora.yml | 4 ++++ vars/default.yml | 4 ++++ 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 vars/Fedora.yml create mode 100644 vars/default.yml diff --git a/handlers/main.yml b/handlers/main.yml index 822887e..8f9c8a1 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,5 @@ --- - name: restart ssh service: - name: ssh + name: "{{ ssh_service }}" state: restarted diff --git a/tasks/main.yml b/tasks/main.yml index 2f03f04..12f2e10 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,8 +1,18 @@ --- + +- name: register os-specific variables + include_vars: default.yml + when: ansible_distribution != 'Fedora' + +- name: register os-specific variables + include_vars: "{{ ansible_distribution }}.yml" + when: ansible_distribution == 'Fedora' + + - name: Collect all users and groups allowed to login via ssh set_fact: - sshd_allow_users: '{{ ["root"] + users.keys() | default({}) | sort }}' - sshd_allow_groups: '{{ ["root"] + users.keys() | default({}) | sort }}' + sshd_allow_users: '{{ ["root", "ansible"] + users.keys() | default({}) | sort }}' + sshd_allow_groups: '{{ ["root", "admins"] + users.keys() | default({}) | sort }}' - name: Copy sshd configuration @@ -45,3 +55,4 @@ - dsa notify: - restart ssh + diff --git a/vars/Fedora.yml b/vars/Fedora.yml new file mode 100644 index 0000000..b25deeb --- /dev/null +++ b/vars/Fedora.yml @@ -0,0 +1,4 @@ +--- + +ssh_service: sshd + diff --git a/vars/default.yml b/vars/default.yml new file mode 100644 index 0000000..d956930 --- /dev/null +++ b/vars/default.yml @@ -0,0 +1,4 @@ +--- + +ssh_service: ssh +