fix variable references

This commit is contained in:
Chris Hammer 2024-11-11 10:40:58 -05:00
parent 5b24f605b6
commit 80a6c3d42a
2 changed files with 11 additions and 10 deletions

View File

@ -3,6 +3,7 @@ verified_reboot_reboot_time: 1 # Time in minutes issued to the shutdown command
verified_reboot_reboot_msg: '*** ANSIBLE INITIATED REBOOT ***' verified_reboot_reboot_msg: '*** ANSIBLE INITIATED REBOOT ***'
verified_reboot_bootid_file: /proc/sys/kernel/random/boot_id verified_reboot_bootid_file: /proc/sys/kernel/random/boot_id
verified_reboot_max_checks: 10 verified_reboot_max_checks: 10
verified_reboot_check_count: 0
# Maximum number of seconds to wait for a connection to happen before closing and retrying. # Maximum number of seconds to wait for a connection to happen before closing and retrying.
verified_reboot_wait_conn_timeout: 20 verified_reboot_wait_conn_timeout: 20

View File

@ -1,17 +1,17 @@
--- ---
- name: Max check count reached - name: Max check count reached
ansible.builtin.fail: ansible.builtin.fail:
msg: "Max check count ({{ max_reboot_check }}) reached. Aborting after {{ reboot_check_count }} tries." msg: "Max check count ({{ verified_reboot_max_checks }}) reached. Aborting after {{ verified_reboot_check_count }} tries."
when: when:
- reboot_check_count | int >= max_reboot_check - verified_reboot_check_count | int >= verified_reboot_max_checks
- name: Increment check count - name: Increment check count
ansible.builtin.set_fact: ansible.builtin.set_fact:
reboot_check_count: "{{ reboot_check_count | int + 1 }}" verified_reboot_check_count: "{{ verified_reboot_check_count | int + 1 }}"
- name: Current Iteration - name: Current Iteration
ansible.builtin.debug: ansible.builtin.debug:
msg: "{{ reboot_check_count }}" msg: "{{ verified_reboot_check_count }}"
verbosity: 1 verbosity: 1
- name: Wait for host to connect or try again - name: Wait for host to connect or try again
@ -28,20 +28,20 @@
- name: Capture boot ID post reboot - name: Capture boot ID post reboot
ansible.builtin.slurp: ansible.builtin.slurp:
src: "{{ bootid_file }}" src: "{{ verified_reboot_bootid_file }}"
register: post_reboot_boot_id_raw register: verified_reboot_post_boot_id_raw
- name: Set post-reboot boot ID - name: Set post-reboot boot ID
ansible.builtin.set_fact: ansible.builtin.set_fact:
post_reboot_boot_id: "{{ post_reboot_boot_id_raw['content'] | b64decode | trim }}" verified_reboot_post_boot_id: "{{ verified_reboot_post_boot_id_raw['content'] | b64decode | trim }}"
- name: Debug boot IDs - name: Debug boot IDs
ansible.builtin.debug: ansible.builtin.debug:
msg: "{{ pre_reboot_boot_id }} == {{ post_reboot_boot_id }}" msg: "{{ verified_reboot_pre_boot_id }} == {{ verified_reboot_post_boot_id }}"
verbosity: 1 verbosity: 1
- name: Re-check host status - name: Re-check host status
ansible.builtin.include_tasks: check_boot_id.yml ansible.builtin.include_tasks: check_boot_id.yml
when: when:
- pre_reboot_boot_id == post_reboot_boot_id - verified_reboot_pre_boot_id == verified_reboot_post_boot_id
- reboot_check_count | int < max_reboot_check - verified_reboot_check_count | int < verified_reboot_max_checks