Skip to content

fix: only install stratis if requested#624

Merged
richm merged 1 commit into
linux-system-roles:mainfrom
richm:fix-stratis-only-if-needed
Jun 4, 2026
Merged

fix: only install stratis if requested#624
richm merged 1 commit into
linux-system-roles:mainfrom
richm:fix-stratis-only-if-needed

Conversation

@richm

@richm richm commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Cause: stratis packages are always installed, and the daemon is always started,
even if the user does not use stratis.

Consequence: The system has unnecessary packages and services.
To maintain a good security posture, no services should be installed
and running if not required.

Fix: Change the code so that stratis packages and services are deployed
only if the user is managing stratis.

Result: The storage role does not install unnecessary packages.

Signed-off-by: Rich Megginson rmeggins@redhat.com

Summary by CodeRabbit

  • New Features

    • Conditional Stratis management: Stratis packages are installed and the stratisd service started/enabled only when Stratis pools/volumes are configured.
  • Documentation

    • Guidance added to omit Stratis packages from ostree images if not managing Stratis.
  • Tests

    • Storage tests updated for Stratis enablement flags and now include cleanup to stop/disable and remove Stratis.
  • Chores

    • Removed Stratis packages from distro package lists and added role variables to manage Stratis packaging.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 88604689-f9d9-4846-a5f2-6620c182cc6b

📥 Commits

Reviewing files that changed from the base of the PR and between de52aa0 and 379c359.

📒 Files selected for processing (9)
  • README-ostree.md
  • tasks/main-blivet.yml
  • tests/tests_stratis.yml
  • vars/Fedora.yml
  • vars/OracleLinux_9.yml
  • vars/RedHat_10.yml
  • vars/RedHat_8.yml
  • vars/RedHat_9.yml
  • vars/main.yml
💤 Files with no reviewable changes (5)
  • vars/OracleLinux_9.yml
  • vars/RedHat_9.yml
  • vars/RedHat_8.yml
  • vars/RedHat_10.yml
  • vars/Fedora.yml
✅ Files skipped from review due to trivial changes (1)
  • README-ostree.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • vars/main.yml
  • tests/tests_stratis.yml
  • tasks/main-blivet.yml

📝 Walkthrough

Walkthrough

The PR makes Stratis package installation conditional: it defines Stratis package variables and a computed enable flag, removes Stratis from distribution default package lists, adds conditional install/service tasks, updates tests (including cleanup), and documents the ostree image note.

Changes

Conditional Stratis Management

Layer / File(s) Summary
Stratis conditional logic foundation
vars/main.yml
Defines _storage_stratis_packages (contains ['stratisd','stratis-cli']) and computes __storage_manage_stratis to detect when Stratis-managed pools/volumes are requested.
Remove Stratis from distribution package lists
vars/Fedora.yml, vars/OracleLinux_9.yml, vars/RedHat_8.yml, vars/RedHat_9.yml, vars/RedHat_10.yml
Removes stratisd and stratis-cli from blivet_package_list across distributions; RedHat_10 adds an architecture-conditional libblockdev-s390 vs libblockdev selector and related comments.
Conditional Stratis installation and service management
tasks/main-blivet.yml
Package installation now includes computed stratis_packages, and a conditional task starts/enables the stratisd service when __storage_manage_stratis is true.
Test coverage and cleanup for conditional Stratis behavior
tests/tests_stratis.yml
Updates test setup (__storage_get_unused_disks, __sr_public) and skip logic for RHEL7/8, removes the prior stratisd start task, and adds an always cleanup that stops/disables stratisd and uninstalls packages listed in __storage_stratis_packages.
Documentation for ostree Stratis removal
README-ostree.md
Adds a note advising users to remove stratisd and stratis-cli from the ostree image package list generation (.ostree/get_ostree_data.sh) when Stratis pools/volumes are not managed.
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description Format ⚠️ Warning PR description uses non-standard sections (Cause, Consequence, Fix) instead of required template format (Enhancement/Feature, Reason, Result). Rewrite PR description to match template: Enhancement (or Feature) section, Reason section, and Result section.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title follows Conventional Commits format with valid type 'fix' and clearly describes the main change: making Stratis installation conditional based on user request.
Description check ✅ Passed The description includes Cause, Consequence, Fix, and Result sections matching the required template structure with clear explanations of the problem and solution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@richm richm requested a review from vojtechtrefny June 3, 2026 20:40
@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 10.16%. Comparing base (59fd1c6) to head (379c359).
⚠️ Report is 145 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (59fd1c6) and HEAD (379c359). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (59fd1c6) HEAD (379c359)
sanity 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #624      +/-   ##
==========================================
- Coverage   16.54%   10.16%   -6.39%     
==========================================
  Files           2        9       +7     
  Lines         284     2056    +1772     
  Branches       79        0      -79     
==========================================
+ Hits           47      209     +162     
- Misses        237     1847    +1610     
Flag Coverage Δ
sanity ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
tasks/main-blivet.yml (1)

77-82: ⚡ Quick win

Use FQCN for service module or add noqa comment.

The service module should use the fully qualified collection name ansible.builtin.service for consistency with other tasks in this file (e.g., ansible.builtin.get_url at line 10, ansible.builtin.apt_repository at line 16). If there's a specific reason to use the short name, add a noqa comment like the mount tasks do at lines 194 and 211.

♻️ Proposed fix
 - name: Ensure stratisd is running and enabled
-  service:
+  ansible.builtin.service:
     name: stratisd
     state: started
     enabled: true
   when: __storage_manage_stratis
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tasks/main-blivet.yml` around lines 77 - 82, The task titled "Ensure stratisd
is running and enabled" uses the short module name "service"; change it to the
fully qualified collection name "ansible.builtin.service" (or if you
intentionally prefer the short name, add a noqa comment like the mount tasks do)
so it matches other tasks (e.g., ansible.builtin.get_url,
ansible.builtin.apt_repository) and avoids lint warnings; update the task where
the name/ module is declared to use ansible.builtin.service (or append the same
noqa pattern used at the mount tasks).
tests/tests_stratis.yml (2)

248-252: 💤 Low value

Use FQCN for service module.

For consistency with the coding guidelines examples, use the fully qualified collection name ansible.builtin.service instead of the short form service.

♻️ Proposed refactor for FQCN consistency
 - name: Ensure stratisd is stopped and disabled
-  service:
+  ansible.builtin.service:
     name: stratisd
     state: stopped
     enabled: false

As per coding guidelines: All examples consistently use FQCN like ansible.builtin.package, ansible.builtin.command, etc.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tests_stratis.yml` around lines 248 - 252, Replace the short module
name "service" with the fully qualified collection name
"ansible.builtin.service" in the task titled "Ensure stratisd is stopped and
disabled": locate the task with name "Ensure stratisd is stopped and disabled"
and change the module key from "service:" to "ansible.builtin.service:" while
keeping the same parameters (name: stratisd, state: stopped, enabled: false).

247-257: 💤 Low value

Consider adding verification for cleanup success.

The cleanup always block stops the service and removes packages, but there are no assertions to verify the cleanup succeeded. Consider adding verification tasks to ensure:

  1. The stratisd service is actually stopped and disabled
  2. The Stratis packages are fully removed
📋 Example verification tasks
- name: Verify stratisd service is stopped
  ansible.builtin.service_facts:
  register: services_after_cleanup
  failed_when: services_after_cleanup.ansible_facts.services['stratisd.service'].state | default('inactive') != 'inactive'

- name: Verify stratis packages are removed
  ansible.builtin.package_facts:
  register: packages_after_cleanup
  failed_when: (packages_after_cleanup.ansible_facts.packages.keys() | list) | intersect(_storage_stratis_packages) | length > 0

As per coding guidelines: "Tests should verify both success and failure scenarios" and "Use assert module to verify expected state after role execution."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tests_stratis.yml` around lines 247 - 257, Add verification tasks after
the existing "Ensure stratisd is stopped and disabled" and "Remove stratis
packages" tasks to assert cleanup succeeded: use ansible.builtin.service_facts
(or service module facts) and fail/ansible.builtin.assert to ensure 'stratisd'
state is inactive/disabled, and use ansible.builtin.package_facts (or
package_facts) and assert to ensure keys intersecting _storage_stratis_packages
is empty; reference the existing task names to insert these checks into the same
always block so the play fails if the service remains active or packages are
still present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README-ostree.md`:
- Around line 9-11: The README instruction is ambiguous: update the text to tell
users to edit the input package list files (not the script output) to remove
stratis packages; specifically instruct them to open the distribution-specific
package list files such as `.ostree/packages-runtime-RedHat-9.txt` and remove
the `stratisd` and `stratis-cli` lines (or any other distro-specific package
file), then re-run `.ostree/get_ostree_data.sh` to regenerate the ostree image
package list; include a short concrete example sentence showing which package
names to remove.

In `@vars/main.yml`:
- Around line 21-23: Rename the internal variable _storage_stratis_packages to
follow the internal naming convention by changing it to
__storage_stratis_packages and update every reference to that variable
throughout the repo (including the place that currently reads
_storage_stratis_packages in the blivet task) so the new name
__storage_stratis_packages is used consistently; ensure you only change the
variable name and its references, preserving value content and YAML structure.

---

Nitpick comments:
In `@tasks/main-blivet.yml`:
- Around line 77-82: The task titled "Ensure stratisd is running and enabled"
uses the short module name "service"; change it to the fully qualified
collection name "ansible.builtin.service" (or if you intentionally prefer the
short name, add a noqa comment like the mount tasks do) so it matches other
tasks (e.g., ansible.builtin.get_url, ansible.builtin.apt_repository) and avoids
lint warnings; update the task where the name/ module is declared to use
ansible.builtin.service (or append the same noqa pattern used at the mount
tasks).

In `@tests/tests_stratis.yml`:
- Around line 248-252: Replace the short module name "service" with the fully
qualified collection name "ansible.builtin.service" in the task titled "Ensure
stratisd is stopped and disabled": locate the task with name "Ensure stratisd is
stopped and disabled" and change the module key from "service:" to
"ansible.builtin.service:" while keeping the same parameters (name: stratisd,
state: stopped, enabled: false).
- Around line 247-257: Add verification tasks after the existing "Ensure
stratisd is stopped and disabled" and "Remove stratis packages" tasks to assert
cleanup succeeded: use ansible.builtin.service_facts (or service module facts)
and fail/ansible.builtin.assert to ensure 'stratisd' state is inactive/disabled,
and use ansible.builtin.package_facts (or package_facts) and assert to ensure
keys intersecting _storage_stratis_packages is empty; reference the existing
task names to insert these checks into the same always block so the play fails
if the service remains active or packages are still present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 76954fe2-6ea8-45b2-b294-9c90784a3226

📥 Commits

Reviewing files that changed from the base of the PR and between 9a8fc68 and 038beef.

📒 Files selected for processing (9)
  • README-ostree.md
  • tasks/main-blivet.yml
  • tests/tests_stratis.yml
  • vars/Fedora.yml
  • vars/OracleLinux_9.yml
  • vars/RedHat_10.yml
  • vars/RedHat_8.yml
  • vars/RedHat_9.yml
  • vars/main.yml
💤 Files with no reviewable changes (5)
  • vars/OracleLinux_9.yml
  • vars/Fedora.yml
  • vars/RedHat_9.yml
  • vars/RedHat_10.yml
  • vars/RedHat_8.yml

Comment thread README-ostree.md
Comment thread vars/main.yml Outdated
@richm richm force-pushed the fix-stratis-only-if-needed branch from 038beef to de52aa0 Compare June 3, 2026 20:55
@richm

richm commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

[citest]

Cause: stratis packages are always installed, and the daemon is always started,
even if the user does not use stratis.

Consequence: The system has unnecessary packages and services.
To maintain a good security posture, no services should be installed
and running if not required.

Fix: Change the code so that stratis packages and services are deployed
only if the user is managing stratis.

Result: The storage role does not install unnecessary packages.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
@richm richm force-pushed the fix-stratis-only-if-needed branch from de52aa0 to 379c359 Compare June 3, 2026 21:57
@richm

richm commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

[citest]

@spetrosi spetrosi left a comment

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.

Nice fix!

@richm richm merged commit 4dc4779 into linux-system-roles:main Jun 4, 2026
42 of 47 checks passed
@richm richm deleted the fix-stratis-only-if-needed branch June 4, 2026 13:01
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.

3 participants