48 lines
1.3 KiB
YAML
48 lines
1.3 KiB
YAML
---
|
|
- name: Max check count reached
|
|
ansible.builtin.fail:
|
|
msg: "Max check count ({{ max_reboot_check }}) reached. Aborting after {{ reboot_check_count }} tries."
|
|
when:
|
|
- reboot_check_count | int >= max_reboot_check
|
|
|
|
- name: Increment check count
|
|
ansible.builtin.set_fact:
|
|
reboot_check_count: "{{ reboot_check_count | int + 1 }}"
|
|
|
|
- name: Current Iteration
|
|
ansible.builtin.debug:
|
|
msg: "{{ reboot_check_count }}"
|
|
|
|
- name: Wait for host to connect or try again
|
|
block:
|
|
- name: Wait for connection
|
|
ansible.builtin.wait_for_connection:
|
|
connect_timeout: 20
|
|
sleep: 10
|
|
delay: 70
|
|
# delay: 10
|
|
timeout: 1800
|
|
# timeout: 10
|
|
rescue:
|
|
- name: Check again - RESCUE
|
|
ansible.builtin.include_tasks: check_boot_id.yml
|
|
|
|
- name: Capture boot ID post reboot
|
|
ansible.builtin.slurp:
|
|
src: "{{ bootid_file }}"
|
|
register: post_reboot_boot_id_raw
|
|
|
|
- name: Set post-reboot boot ID
|
|
ansible.builtin.set_fact:
|
|
post_reboot_boot_id: "{{ post_reboot_boot_id_raw['content'] | b64decode | trim }}"
|
|
|
|
- name: Debug boot IDs
|
|
ansible.builtin.debug:
|
|
msg: "{{ pre_reboot_boot_id }} == {{ post_reboot_boot_id }}"
|
|
|
|
- name: Check again
|
|
ansible.builtin.include_tasks: check_boot_id.yml
|
|
when:
|
|
- pre_reboot_boot_id == post_reboot_boot_id
|
|
- reboot_check_count | int < max_reboot_check
|