--- - name: Something hosts: bigboot become: false gather_facts: false vars: bootid_file: /proc/sys/kernel/random/boot_id reboot_extra_time: 120 tasks: - name: Capture initial boot ID ansible.builtin.slurp: src: "{{ bootid_file }}" register: pre_reboot_boot_id_raw - name: Set pre-reboot boot ID ansible.builtin.set_fact: pre_reboot_boot_id: "{{ pre_reboot_boot_id_raw['content'] | b64decode | trim }}" # - name: Reboot the host # ansible.builtin.command: # cmd: "/usr/sbin/shutdown -r +1 '*** ANSIBLE INITIATED REBOOT ***'" # re-write tomorrow with async/poll # i dont know what the above was meant to accomplish # but perhaps we should create our own '.nologin' file # ...may need to be cleaned up post-reboot # # verify systemd service dependancy also; meaning # can we create a service dependant on another # and does it auto-start the service it depends on... # # async/poll was for a block to check the proc file, and continue if id's # differ, else sleep (for 1min?) and then try again until success or max # polls are reached - name: Verify reboot status of host ansible.builtin.include_tasks: tasks/check_boot_id.yml # - name: Assert that the post-reboot ID differs from the pre-reboot ID # ansible.builtin.assert: # that: pre_reboot_boot_id != post_reboot_boot_id # success_msg: "System rebooted successfully. Boot ID's differ." # fail_msg: "System did not reboot. Boot ID's match" # - name: Giving the host extra time to complete its reboot # ansible.builtin.pause: # seconds: "{{ reboot_extra_time }}" # - name: Assert that the system has rebooted # ansible.builtin.assert: # that: pre_reboot_boot_id != post_reboot_boot_id # success_msg: "System rebooted successfully. Boot ID's differ." # fail_msg: "System did not reboot. Boot ID's match"