workstation/roles/distro/tasks/ssh.yml

35 lines
839 B
YAML
Raw Normal View History

2019-10-05 19:33:23 +00:00
---
- name: Disable SSH passwords
become: true
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?\w*PasswordAuthentication (yes|no)'
line: 'PasswordAuthentication no'
register: changed_ssh_config
2019-10-11 14:05:31 +00:00
- name: Enable SSH (Linux)
become: true
systemd:
name: ssh.service
enabled: yes
state: started
when: ansible_system == 'Linux'
- name: Enable SSH (FreeBSD)
2019-10-05 19:33:23 +00:00
become: true
2019-10-10 18:45:35 +00:00
service:
2019-10-11 14:05:31 +00:00
name: sshd
2019-10-05 19:33:23 +00:00
enabled: yes
state: started
2019-10-11 14:05:31 +00:00
when: ansible_system == 'FreeBSD'
- name: Restart SSH (Linux)
become: true
systemd:
name: ssh.service
state: restarted
when: changed_ssh_config.changed == true and ansible_system == 'Linux'
- name: Restart SSH (FreeBSD)
2019-10-05 19:33:23 +00:00
become: true
2019-10-10 18:45:35 +00:00
service:
2019-10-11 14:05:31 +00:00
name: sshd
2019-10-05 19:33:23 +00:00
state: restarted
2019-10-11 14:05:31 +00:00
when: changed_ssh_config.changed == true and ansible_system == 'FreeBSD'