Commit 5ab15cdf authored by Alain Takoudjou's avatar Alain Takoudjou

fix restart of sshd deamon at every run

parent b6f077a5
...@@ -45,14 +45,17 @@ ...@@ -45,14 +45,17 @@
authorized_key: user=root key="{{ lookup('file', '/etc/opt/authorized_keys') }}" authorized_key: user=root key="{{ lookup('file', '/etc/opt/authorized_keys') }}"
when: authorized_keys.stat.exists == True when: authorized_keys.stat.exists == True
- name: update /etc/ssh/sshd_config - name: Check whether sshd_config is well configured
lineinfile: dest=/etc/ssh/sshd_config regexp="^PermitRootLogin (?!no)" line="PermitRootLogin no" command: grep -wq "^PermitRootLogin no" /etc/ssh/sshd_config
notify: register: permitrootlogin
- restart ssh always_run: True
- restart sshd ignore_errors: True
changed_when: False
- name: update /etc/ssh/sshd_config - name: update /etc/ssh/sshd_config
lineinfile: dest=/etc/ssh/sshd_config line="PermitRootLogin no" lineinfile: dest=/etc/ssh/sshd_config regexp="^PermitRootLogin (.*)" line="PermitRootLogin no" state=present
notify: notify:
- restart ssh - restart ssh
- restart sshd - restart sshd
when: permitrootlogin.rc != 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment