2019-11-20 10:07:43 +00:00
|
|
|
---
|
|
|
|
- name: Disable SSH passwords
|
|
|
|
become: true
|
2021-02-19 20:32:22 +00:00
|
|
|
ansible.builtin.lineinfile:
|
2019-11-20 10:07:43 +00:00
|
|
|
path: /etc/ssh/sshd_config
|
|
|
|
regexp: '^#?\w*PasswordAuthentication (yes|no)'
|
|
|
|
line: 'PasswordAuthentication no'
|
|
|
|
register: changed_ssh_config
|
|
|
|
- name: Enable SSH
|
|
|
|
become: true
|
2021-02-19 20:32:22 +00:00
|
|
|
ansible.builtin.systemd:
|
2019-11-20 10:07:43 +00:00
|
|
|
name: ssh.service
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
|
|
|
- name: Restart SSH
|
|
|
|
become: true
|
2021-02-19 20:32:22 +00:00
|
|
|
ansible.builtin.systemd:
|
2019-11-20 10:07:43 +00:00
|
|
|
name: ssh.service
|
|
|
|
state: restarted
|
|
|
|
when: changed_ssh_config.changed == true
|