diff --git a/playbooks/diagnose.yml b/playbooks/diagnose.yml new file mode 100644 index 0000000..69d0998 --- /dev/null +++ b/playbooks/diagnose.yml @@ -0,0 +1,31 @@ +--- +- name: Diagnose and fix SSH on localhost + hosts: localhost + become: yes + tasks: + - name: Check sshd service status + ansible.builtin.command: systemctl status sshd --no-pager + register: sshd_status + ignore_errors: yes + + - name: Show sshd status + ansible.builtin.debug: + var: sshd_status.stdout_lines + + - name: Check listening ports + ansible.builtin.shell: ss -tlnp | grep -E ':22|:2222' + register: ports + ignore_errors: yes + + - name: Show ports + ansible.builtin.debug: + var: ports.stdout_lines + + - name: Test sshd configuration + ansible.builtin.command: sshd -t + register: sshd_test + ignore_errors: yes + + - name: Show config test result + ansible.builtin.debug: + var: sshd_test.stderr \ No newline at end of file