Disable SSH password auth in the common role only when sshd is active
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
- name: Check if SSH daemon is active
|
||||||
|
systemd:
|
||||||
|
name: sshd
|
||||||
|
state: started
|
||||||
|
register: sshd_status
|
||||||
|
|
||||||
|
- block:
|
||||||
- name: Disable SSH password auth
|
- name: Disable SSH password auth
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: /etc/ssh/sshd_config
|
dest: /etc/ssh/sshd_config
|
||||||
@@ -10,3 +17,4 @@
|
|||||||
name: sshd
|
name: sshd
|
||||||
state: restarted
|
state: restarted
|
||||||
when: sshd_config.changed
|
when: sshd_config.changed
|
||||||
|
when: sshd_status.status.ActiveState == 'active'
|
||||||
|
|||||||
Reference in New Issue
Block a user