From d77c2b7e46aede86d01a795af5ca8b61af3ae819 Mon Sep 17 00:00:00 2001 From: Anthony Perkins Date: Fri, 11 Oct 2019 15:05:31 +0100 Subject: [PATCH] Configure ssh for FreeBSD --- roles/distro/tasks/ssh.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/roles/distro/tasks/ssh.yml b/roles/distro/tasks/ssh.yml index 5c0e194..e831a56 100644 --- a/roles/distro/tasks/ssh.yml +++ b/roles/distro/tasks/ssh.yml @@ -6,15 +6,29 @@ regexp: '^#?\w*PasswordAuthentication (yes|no)' line: 'PasswordAuthentication no' register: changed_ssh_config -- name: Enable SSH +- name: Enable SSH (Linux) become: true - service: - name: ssh + systemd: + name: ssh.service enabled: yes state: started -- name: Restart SSH + when: ansible_system == 'Linux' +- name: Enable SSH (FreeBSD) become: true service: - name: ssh + name: sshd + enabled: yes + state: started + when: ansible_system == 'FreeBSD' +- name: Restart SSH (Linux) + become: true + systemd: + name: ssh.service state: restarted - when: changed_ssh_config.changed == true + when: changed_ssh_config.changed == true and ansible_system == 'Linux' +- name: Restart SSH (FreeBSD) + become: true + service: + name: sshd + state: restarted + when: changed_ssh_config.changed == true and ansible_system == 'FreeBSD'