Skip to content

[WIP] Add RebootRequired fact for detecting system reboot needs #1310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 3.x
Choose a base branch
from

Conversation

wowi42
Copy link
Contributor

@wowi42 wowi42 commented Mar 12, 2025

Introduces a new fact to check if a system requires a reboot across different Unix-like systems:

  • Linux: Checks /var/run/reboot-required files and Alpine Linux kernel comparison
  • FreeBSD: Compares running and installed kernel versions

Supports detection methods for Linux and FreeBSD systems with a flexible shell script approach.

wowi42 added 4 commits March 12, 2025 09:25
Introduces a new fact to check if a system requires a reboot across different Unix-like systems:
- Linux: Checks /var/run/reboot-required files and Alpine Linux kernel comparison
- FreeBSD: Compares running and installed kernel versions

Supports detection methods for Linux and FreeBSD systems with a flexible shell script approach.
Adds comprehensive test cases for the RebootRequired fact across different Unix-like systems:
- Alpine Linux kernel version comparison test
- Linux standard reboot required file test
- FreeBSD kernel version comparison test
- Linux no reboot required scenario test

These test cases validate the detection logic for various system reboot scenarios.
Refactor the release metadata dictionary comprehension to a single line, removing unnecessary line breaks while preserving the original logic of converting OS release info keys to uppercase.
@wowi42 wowi42 changed the title Add RebootRequired fact for detecting system reboot needs [WIP] Add RebootRequired fact for detecting system reboot needs Mar 25, 2025
@wowi42
Copy link
Contributor Author

wowi42 commented Mar 25, 2025

not sure if it is the best way to do it

Copy link
Member

@Fizzadar Fizzadar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's some extra test args but otherwise this looks good. The script is somewhat hacky but there's no real alternative with the way facts work today.

"reboot_required"
],
"fact": true,
"setup": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this key does anything?

def command(self) -> str:
return """
# Get OS type
OS_TYPE=$(uname -s)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, the problem of facts being unable to call each other. Unfortunately I think this is the best way we can currently do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants