verified_reboot/tasks/check_boot_id.yml

39 lines
1.4 KiB
YAML

---
- name: Wait for connection to host
ansible.builtin.wait_for_connection:
connect_timeout: "{{ verified_reboot_wait_conn_timeout }}"
sleep: "{{ verified_reboot_wait_sleep }}"
delay: "{{ verified_reboot_wait_delay }}"
timeout: "{{ verified_reboot_wait_timeout }}"
- name: Increment check count
ansible.builtin.set_fact:
verified_reboot_check_count:
"{{ 1 if verified_reboot_check_count is undefined else verified_reboot_check_count | int + 1 }}"
- name: Capture post-reboot boot ID
ansible.builtin.slurp:
src: "{{ verified_reboot_bootid_file }}"
register: verified_reboot_post_boot_id_raw
- name: Set post-reboot boot ID
ansible.builtin.set_fact:
verified_reboot_post_boot_id: "{{ verified_reboot_post_boot_id_raw['content'] | b64decode | trim }}"
- name: Debug boot IDs
ansible.builtin.debug:
msg: "{{ verified_reboot_pre_boot_id }} == {{ verified_reboot_post_boot_id }}"
verbosity: 1
- name: Max check count exception
ansible.builtin.fail:
msg: "Max check count ({{ verified_reboot_max_checks }}) reached. Aborting."
when:
- verified_reboot_check_count | int >= verified_reboot_max_checks
- name: Re-check host reboot status
ansible.builtin.include_tasks: check_boot_id.yml
when:
- verified_reboot_pre_boot_id == verified_reboot_post_boot_id
- verified_reboot_check_count | int < verified_reboot_max_checks