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

fix restart of sshd deamon at every run

parent b6f077a5
......@@ -45,14 +45,17 @@
authorized_key: user=root key="{{ lookup('file', '/etc/opt/authorized_keys') }}"
when: authorized_keys.stat.exists == True
- name: update /etc/ssh/sshd_config
lineinfile: dest=/etc/ssh/sshd_config regexp="^PermitRootLogin (?!no)" line="PermitRootLogin no"
notify:
- restart ssh
- restart sshd
- name: Check whether sshd_config is well configured
command: grep -wq "^PermitRootLogin no" /etc/ssh/sshd_config
register: permitrootlogin
always_run: True
ignore_errors: True
changed_when: False
- 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:
- restart ssh
- 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