Commit 6b13826b authored by Alain Takoudjou's avatar Alain Takoudjou

Merge branch 'logging' into 'master'

Logging

See merge request !18
parents 7436ece4 8f16b9c1
...@@ -61,6 +61,10 @@ ...@@ -61,6 +61,10 @@
- name: Delete default nameserver - name: Delete default nameserver
lineinfile: dest=/etc/resolv.conf line="nameserver 10.0.2.3" state=absent lineinfile: dest=/etc/resolv.conf line="nameserver 10.0.2.3" state=absent
- name: Turn off dhclient if it's running
shell: pkill dhclient
ignore_errors: True
- name: ping current host - name: ping current host
script: ping host {{ lookup('file', '/etc/opt/ipv4') }} {{ lookup('file', '/etc/opt/hostname') }} script: ping host {{ lookup('file', '/etc/opt/ipv4') }} {{ lookup('file', '/etc/opt/hostname') }}
when: hostname_file.stat.exists == True when: hostname_file.stat.exists == True
......
...@@ -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: 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 - name: update /etc/ssh/sshd_config
lineinfile: dest=/etc/ssh/sshd_config regexp="^PermitRootLogin (?!no)" 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
- name: update /etc/ssh/sshd_config
lineinfile: dest=/etc/ssh/sshd_config line="PermitRootLogin no"
notify:
- restart ssh
- restart sshd
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