From 5d019d2ad90c39cfae2d7edf0208c98060ddbd8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Sat, 14 Jan 2023 19:02:36 +0100 Subject: feat(roles/sshd): add argument specs --- roles/sshd/tasks/main.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'roles/sshd/tasks') diff --git a/roles/sshd/tasks/main.yml b/roles/sshd/tasks/main.yml index b895958..6a622d2 100644 --- a/roles/sshd/tasks/main.yml +++ b/roles/sshd/tasks/main.yml @@ -9,15 +9,26 @@ - name: generate sshd configuration ansible.builtin.template: src: sshd_config.j2 - dest: /etc/ssh/sshd_config + dest: "{{ sshd_configuration_file }}" owner: 0 group: 0 mode: "0644" + register: sshd_result_generate_configuration -- name: enable and restart sshd +- name: lint sshd configuration + ansible.builtin.command: "sshd -tf {{ sshd_configuration_file }}" + register: sshd_result_lint + changed_when: false + +- name: restart sshd # noqa: no-handler ansible.builtin.service: name: sshd state: restarted + when: sshd_result_generate_configuration.changed + +- name: enable sshd + ansible.builtin.service: + name: sshd enabled: true - name: check ssh connection -- cgit v1.2.3