From 5e3e7cae9748faedf73c711137e27d080db3a4f2 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Fri, 12 Apr 2024 21:41:11 +0000 Subject: [PATCH] Use handler --- .../playground/roles/ssh_config/handlers/main.yml | 6 +++++- slococo/playground/roles/ssh_config/tasks/main.yml | 13 ------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/slococo/playground/roles/ssh_config/handlers/main.yml b/slococo/playground/roles/ssh_config/handlers/main.yml index 73b314f..fa583fc 100644 --- a/slococo/playground/roles/ssh_config/handlers/main.yml +++ b/slococo/playground/roles/ssh_config/handlers/main.yml @@ -1 +1,5 @@ ---- \ No newline at end of file +--- +- name: Restart SSH service + ansible.builtin.service: + name: sshd + state: restarted \ No newline at end of file diff --git a/slococo/playground/roles/ssh_config/tasks/main.yml b/slococo/playground/roles/ssh_config/tasks/main.yml index 8e887ec..bf6795b 100644 --- a/slococo/playground/roles/ssh_config/tasks/main.yml +++ b/slococo/playground/roles/ssh_config/tasks/main.yml @@ -7,17 +7,4 @@ state: present validate: "sshd -t -f %s" loop: "{{ sshd_options | dict2items }}" - register: sshd_config become: true - -- name: Restart SSH service - ansible.builtin.service: - name: sshd - state: restarted - when: sshd_config.changed - -# - name: Ensure SSH daemon configuration is consistent -# ansible.builtin.command: sshd -t -f /etc/ssh/sshd_config -# changed_when: sshd_config.changed -# notify: Restart SSH Service -# become: true