Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit ad4a8a0

Browse files
committed
Merge pull request #11 from hardening-io/use_handler
Add handler to restart ssh only if necessary. Fix #6
2 parents 1d4dac1 + ef275a4 commit ad4a8a0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- name: restart sshd
2+
service: name={{ sshd_service_name }} state=restarted

roles/ansible-ssh-hardening/tasks/main.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
include_vars: "{{ ansible_os_family }}.yml"
44

55
- name: create sshd_config and set permissions to root/600
6-
template: src='opensshd.conf.j2' dest='/etc/ssh/sshd_config' mode=0600 owner=root group=root
6+
template: src='opensshd.conf.j2' dest='/etc/ssh/sshd_config' mode=0600 owner=root group=root validate="/usr/sbin/sshd -T -f %s"
7+
notify: restart sshd
78

89
- name: create ssh_config and set permissions to root/644
910
template: src='openssh.conf.j2' dest='/etc/ssh/ssh_config' mode=0644 owner=root group=root
10-
11-
- name: restart sshd
12-
service: name={{ sshd_service_name }} state=restarted

0 commit comments

Comments
 (0)