{"id":5628,"sha1":"11a5df672dc4acc814ca6e5d5a9876e43e791bcc","playbook":{"id":3508,"items":{"plays":1,"tasks":10,"results":10,"hosts":1,"files":1,"records":0},"arguments":{"version":null,"verbosity":0,"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/bash-kvm-inventory-prod.sh"],"listhosts":false,"subset":"versatile-chipmunk.man-1.vm.plesk-server.com","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":["RM10092_agent360_conf_change.yaml"]},"labels":[{"id":1,"name":"remote_user:root"},{"id":2,"name":"check:False"},{"id":3,"name":"tags:all"},{"id":80,"name":"subset:versatile-chipmunk.man-1.vm.plesk-server.com"}],"started":"2025-07-24T12:15:27.252616+01:00","ended":"2025-07-24T12:15:35.639949+01:00","duration":"00:00:08.387333","name":null,"ansible_version":"2.16.11","client_version":"1.7.2","python_version":"3.10.10","server_version":"1.7.2","status":"completed","path":"/home/ssh-gateway/ansible/kuly/RM10092_agent360_conf_change.yaml","controller":"ssh-gw-4.layershift.com","user":"root"},"content":"---\n- name: Search for diskusage block in file and replace it\n  hosts: all\n  gather_facts: false\n  vars:\n    config_file: \"/etc/agent360.ini\"\n  tasks:\n    - name: Check if block was found\n      ansible.builtin.shell: \"grep -q '^\\\\[diskusage\\\\]$' {{ config_file }} && echo 'found' || echo 'not found'\"\n      register: block_exists\n      changed_when: false\n\n    - name: Display message if block not found\n      ansible.builtin.debug:\n        msg: \"Block [diskusage] not found in the file\"\n      when: block_exists.stdout == \"not found\"\n\n    - name: Run actions if block found\n      when: block_exists.stdout == \"found\"\n      block:\n        - name: Replace diskusage block with new content\n          ansible.builtin.replace:\n            path: \"{{ config_file }}\"\n            regexp: |\n              (?sm)^\\[diskusage\\].*?^(?=\\[.*\\]|$)\n            replace: |\n              [diskusage]\n              enabled = true\n              exclude = /dev/loop,/dev/snap,/squashfs,/cagefs-skeleton,/restore\\n\n            backup: true\n            owner: agent360\n            mode: '0600'\n          register: replace_result\n        - name: Display replacement result\n          ansible.builtin.debug:\n            msg: \"Successfully replaced diskusage block\"\n          when: replace_result.changed\n        - name: Display message when no changes were needed\n          ansible.builtin.debug:\n            msg: \"No changes made to the file\"\n          when: not replace_result.changed\n        - name: Restart agent360 service\n          ansible.builtin.systemd:\n            name: agent360\n            state: restarted\n      always:\n        - name: Check service status\n          ansible.builtin.shell: |\n            set -o pipefail\n            service_time=$(systemctl show -p ActiveEnterTimestamp agent360.service | awk -F'=' '{print $2}')\n            service_epoch=$(date -d \"$service_time\" +%s)\n            current_time=$(date +%s)\n            time_diff=$((current_time - service_epoch))\n            echo $time_diff\n          args:\n            executable: /bin/bash\n          register: time_difference_output\n          changed_when: false\n        - name: Determine if service was restarted recently\n          ansible.builtin.debug:\n            msg: \"Service was restarted recently.\"\n          when: time_difference_output.stdout | int > 1 and time_difference_output.stdout | int < 300\n        - name: Get services status\n          ansible.builtin.service_facts:\n        - name: Write to a file the failed one\n          when: '\"running\" not in ansible_facts.services[\"agent360.service\"].state'\n          ansible.builtin.lineinfile:\n            path: /home/ssh-gateway/ansible/kuly/stopped.txt\n            create: true\n            mode: '0644'\n            line: '{{ inventory_hostname }} is not running'\n          delegate_to: localhost\n","created":"2025-07-24T12:15:27.271023+01:00","updated":"2025-07-24T12:15:27.271045+01:00","path":"/home/ssh-gateway/ansible/kuly/RM10092_agent360_conf_change.yaml"}