{"id":5929,"sha1":"83cc08f5a241f68d5b244c444635559664d16ddc","playbook":{"id":3809,"items":{"plays":2,"tasks":0,"results":0,"hosts":0,"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-dev"],"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":["RM10132_kvm_restart_required.yaml"]},"labels":[{"id":1,"name":"remote_user:root"},{"id":2,"name":"check:False"},{"id":3,"name":"tags:all"}],"started":"2025-09-16T09:30:21.602767+01:00","ended":"2025-09-16T09:30:21.953774+01:00","duration":"00:00:00.351007","name":null,"ansible_version":"2.16.11","client_version":"1.7.3","python_version":"3.10.10","server_version":"1.7.3","status":"completed","path":"/home/ssh-gateway/ansible/kuly/RM10132_kvm_restart_required.yaml","controller":"ssh-gw-4.layershift.com","user":"root"},"content":"---\n- name: Process KVM Hosts That Require Restart\n  hosts: all\n  gather_facts: false\n\n  tasks:\n    - name: Check if system needs restarting\n      kvm_upgrade_utils:\n        action: check_restart\n      register: restart_status\n      changed_when: restart_status.needs_restarting\n\n    - name: Display restart requirement status\n      ansible.builtin.debug:\n        msg: |\n          Host: {{ inventory_hostname }}\n          {% if restart_status.needs_restarting %}\n          \ud83d\udea8 RESTART REQUIRED\n          {% else %}\n          \u2705 No restart needed\n          {% endif %}\n      changed_when: restart_status.needs_restarting\n\n    - name: Set fact for hosts requiring restart\n      ansible.builtin.set_fact:\n        host_needs_restart: \"{{ restart_status.needs_restarting }}\"\n      delegate_to: localhost\n      delegate_facts: true\n      run_once: true\n\n- name: Process hosts that need restart\n  hosts: all\n  gather_facts: false\n  serial: 1\n\n  tasks:\n    - name: Check if this host needs restart\n      ansible.builtin.debug:\n        msg: \"Checking restart status for {{ inventory_hostname }}\"\n      delegate_to: localhost\n      run_once: true\n\n    - name: Perform restart actions for hosts that need it\n      ansible.builtin.debug:\n        msg: |\n          ========================================\n          Processing restart for: {{ inventory_hostname }}\n          ========================================\n          \ud83d\udea8 RESTART ACTIONS REQUIRED:\n          1. Schedule maintenance window\n          2. Migrate VMs if possible\n          3. Notify customers\n          4. Reboot host\n          5. Verify services after restart\n          ========================================\n      when: hostvars[inventory_hostname]['restart_status']['needs_restarting'] | default(false)\n      changed_when: true\n\n    - name: Skip hosts that don't need restart\n      ansible.builtin.debug:\n        msg: \"\u2705 {{ inventory_hostname }}: No restart required, skipping...\"\n      when: not (hostvars[inventory_hostname]['restart_status']['needs_restarting'] | default(false))\n","created":"2025-09-16T09:30:21.642636+01:00","updated":"2025-09-16T09:30:21.642656+01:00","path":"/home/ssh-gateway/ansible/kuly/RM10132_kvm_restart_required.yaml"}