{"id":6627,"sha1":"74d0b7c02b4b4b6531344aa78465f3e422cdebdc","playbook":{"id":4501,"items":{"plays":1,"tasks":4,"results":12,"hosts":3,"files":1,"records":0},"arguments":{"version":null,"verbosity":2,"private_key_file":"/home/ssh-gateway/.ssh/id_rsa","remote_user":"root","connection":"ssh","timeout":null,"ssh_common_args":null,"sftp_extra_args":null,"scp_extra_args":null,"ssh_extra_args":null,"ask_pass":false,"connection_password_file":null,"force_handlers":false,"flush_cache":false,"become":false,"become_method":"sudo","become_user":null,"become_ask_pass":false,"become_password_file":null,"tags":["all"],"skip_tags":[],"check":false,"diff":false,"inventory":["/home/ssh-gateway/ansible/kuly/test-stage-hosts"],"listhosts":false,"subset":null,"extra_vars":"Not saved by ARA as configured by 'ignored_arguments'","vault_ids":[],"ask_vault_pass":false,"vault_password_files":[],"forks":20,"module_path":null,"syntax":false,"listtasks":false,"listtags":false,"step":false,"start_at_task":null,"args":["RM10193-sshd-config-changes.yaml"]},"labels":[{"id":1,"name":"remote_user:root"},{"id":2,"name":"check:False"},{"id":3,"name":"tags:all"}],"started":"2025-11-20T12:00:19.994029Z","ended":"2025-11-20T12:00:23.514387Z","duration":"00:00:03.520358","name":null,"ansible_version":"2.16.11","client_version":"1.7.3","python_version":"3.10.10","server_version":"1.7.3","status":"failed","path":"/home/ssh-gateway/ansible/kuly/RM10193-sshd-config-changes.yaml","controller":"ssh-gw-4.layershift.com","user":"root"},"content":"---\n- name: Playbook to make sshd changes\n  hosts: all\n  gather_facts: false\n  vars:\n    sshd_config_path: /etc/ssh/sshd_config\n    sshd_hardening_params:\n      - {regexp: '^#?AllowAgentForwarding', line: 'AllowAgentForwarding no'}\n      - {regexp: '^#?AllowTcpForwarding', line: 'AllowTcpForwarding no'}\n      - {regexp: '^#?X11Forwarding', line: 'X11Forwarding no'}\n    sshd_port: 2233\n  tasks:\n    - name: Ensure SSHD config file exists before proceeding\n      ansible.builtin.stat:\n        path: \"{{ sshd_config_path }}\"\n      register: sshd_config_stat\n      failed_when: not sshd_config_stat.stat.exists\n    - name: Make the replacements\n      ansible.builtin.lineinfile:\n        path: \"{{ sshd_config_path }}\"\n        regexp: \"{{ item.regexp }}\"\n        line: \"{{ item.line }}\"\n        state: present\n        backup: true\n        validate: 'sshd -t -f %s'\n      loop: \"{{ sshd_hardening_params }}\"\n      register: sshd_config_results\n      notify: Restart SSHD Service\n\n    - name: Check if any configuration changes occurred for wait_for task\n      ansible.builtin.set_fact:\n        config_changed: \"{{ sshd_config_results.changed | bool }}\"\n\n    - name: Wait for SSH\n      ansible.builtin.wait_for:\n        port: \"{{ ssh_port }}\"\n        host: \"{{ ansible_host }}\"\n        timeout: 60\n        delay: 5\n        search_regex: ssh\n      when: config_changed | bool\n\n  handlers:\n    - name: Restart SSHD Service\n      ansible.builtin.systemd:\n        name: sshd\n        state: restarted\n        daemon_reload: true\n      listen: \"Restart SSHD Service\"\n","created":"2025-11-20T12:00:20.029942Z","updated":"2025-11-20T12:00:20.029968Z","path":"/home/ssh-gateway/ansible/kuly/RM10193-sshd-config-changes.yaml"}