Files
Kamino/roles/system_baseline/tasks/reboot.yml
T
Dragonish 26b6e37a09
Build / build (pull_request) Successful in 34s
Lint / lint (pull_request) Successful in 2m32s
Molecule / molecule (pull_request) Canceled after 6m34s
fix: read facts through ansible_facts and run Molecule with fact injection off
ansible-core deprecates injecting facts as top-level variables (removal is
scheduled for 2.24, see #364). Three roles still read a bare fact: system_baseline (reboot check,
ansible_os_family), docker (APT source line, ansible_distribution_release)
and gitea_runner (re-registration backup name, ansible_date_time). With
inject_facts_as_vars set to false the system_baseline reboot check failed
with "'ansible_os_family' is undefined".

They now read ansible_facts[...]; the argument specs and READMEs that name
the facts follow. run_molecule_in_ci_image.sh exports
ANSIBLE_INJECT_FACT_VARS=False, so a role that reads an injected fact fails
its scenario, and a script test keeps the export in place.

Refs #364

Assisted-by: Claude Code:claude-sonnet-5-5
2026-11-26 21:33:03 +00:00

27 lines
991 B
YAML

---
# The tasks_from: reboot entry point does not run validate.yml, so the reboot inputs are checked here as well.
- name: Validate the reboot inputs
ansible.builtin.import_tasks: validate_reboot.yml
- name: Check if reboot required (Debian)
when: ansible_facts['os_family'] == "Debian"
block:
- name: Check if reboot is required (Debian)
ansible.builtin.stat:
path: /var/run/reboot-required
register: system_baseline_reboot_required_file
- name: Set system_baseline_reboot_required fact
ansible.builtin.set_fact:
system_baseline_reboot_required: "{{ system_baseline_reboot_required_file.stat.exists }}"
- name: Reboot the server if required
ansible.builtin.reboot:
reboot_timeout: 900
post_reboot_delay: "{{ system_baseline_reboot_post_delay | int }}"
throttle: "{{ system_baseline_reboot_throttle | int }}"
become: true
when:
- system_baseline_reboot_if_required
- system_baseline_reboot_required | default(false)