Skip to content

Move feature plugin package installs to Python for image mode support#4800

Draft
thrix wants to merge 1 commit intoissue-4606from
feature-plugins-image-mode
Draft

Move feature plugin package installs to Python for image mode support#4800
thrix wants to merge 1 commit intoissue-4606from
feature-plugins-image-mode

Conversation

@thrix
Copy link
Copy Markdown
Contributor

@thrix thrix commented Apr 15, 2026

Move package installations from Ansible playbooks to Python code using guest.package_manager.install() which works on both regular and image mode (bootc) guests. Playbooks now only handle /etc and /var mutations.

Add distro_id and distro_major_version facts to GuestFacts.

Fix FIPS is_ostree guard to allow image mode guests.

Fixes #4625

Depends on #4719 which adds testing support for image mode.

Assisted-by: Claude Code

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • update the specification
  • adjust plugin docstring
  • modify the json schema
  • mention the version
  • include a release note

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request transitions package installation for EPEL and FIPS features from Ansible playbooks to Python code to support image-mode guests with immutable filesystems. It also introduces distro_id and distro_major_version guest facts. Feedback suggests adding error handling for non-numeric VERSION_ID values during integer conversion to prevent potential crashes.

Comment thread tmt/guest/__init__.py
def _query_distro_major_version(self, guest: 'Guest') -> Optional[int]:
version_id = self.os_release_content.get('VERSION_ID')
if version_id:
return int(version_id.split('.')[0])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Handle non-numeric VERSION_ID values (e.g., 'rawhide') to avoid a ValueError during integer conversion. An explicit return None is included in the exception handler to maintain clarity, aligning with repository preferences for explicit returns.

Suggested change
return int(version_id.split('.')[0])
try:
return int(version_id.split('.')[0])
except ValueError:
return None
References
  1. An explicit return None at the end of a function may be preferred for clarity, even if it is considered unreachable by static analysis.

else:
guest.package_manager.install(Package("dnf-command(config-manager)"))
# EPEL Next is available for CentOS Stream 9
# Enable for Stream 10 once epel-next is available
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
# Enable for Stream 10 once epel-next is available

What? This would never happen. Seems like legacy comment

if version == 9:
guest.package_manager.install(Package("epel-next-release"))

cls._run_playbook('enable', "epel-enable.yaml", guest, logger)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there value of keeping the remaining playbook?

Move package installations from Ansible playbooks to Python code using
`guest.package_manager.install()` which works on both regular and image
mode (bootc) guests. Playbooks now only handle `/etc` and `/var` mutations.

Add `distro_id` and `distro_major_version` facts to `GuestFacts`.

Fix FIPS `is_ostree` guard to allow image mode guests.

Fixes #4625

Assisted-by: Claude Code
Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.com>
@thrix thrix force-pushed the feature-plugins-image-mode branch from feef056 to b9094a5 Compare April 17, 2026 03:18
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