Skip to content
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

modprobe: fix --check mode not being honored for persistent option #9052

Conversation

salmon111
Copy link

SUMMARY

This change fixes an issue in the community.general.modprobe module where the --check mode was not being honored when the persistent option was set.
Previously, even in --check mode, the module would attempt to modify system files, which is not the expected behavior.
With this fix, when --check mode is enabled, the module will simulate the changes without making any modifications to the system, ensuring correct dry-run behavior.

Fixes #9051

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

modprobe

ADDITIONAL INFORMATION
  1. Create an Ansible playbook with the following task
- name: Load dummy module
  community.general.modprobe:
    name: dummy
    persistent: present
    # persistent: absent
  1. Run the playbook in --check mode
ansible-playbook playbook.yml --check
  1. Observe that the module modifies the system even in --check mode, which should not happen.

After the fix:

  • Running the playbook in --check mode will no longer apply changes to the system, and will only simulate the action.

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) labels Oct 22, 2024
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-8 Automatically create a backport for the stable-8 branch backport-9 Automatically create a backport for the stable-9 branch backport-7 labels Oct 22, 2024
Co-authored-by: Felix Fontein <felix@fontein.de>
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Looks good to me! If nobody objects, I'll merge this in a week.

@salmon111
Copy link
Author

Thank you for the review!

Copy link
Collaborator

@russoz russoz left a comment

Choose a reason for hiding this comment

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

LGTM

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Oct 28, 2024
@felixfontein felixfontein merged commit d0b4e91 into ansible-collections:main Oct 28, 2024
126 checks passed
Copy link

patchback bot commented Oct 28, 2024

Backport to stable-7: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-7/d0b4e91cac95b2b3c0984704799b1f1f2d4ce8b8/pr-9052

Backported as #9069

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Oct 28, 2024
…9052)

* modprobe: fix --check mode not being honored for persistent option

* Add CHANGELOG

* Update CHANGELOG

* Update changelogs/fragments/9052-modprobe-bugfix.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: d-usuba <d-usuba@sakura.ad.jp>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit d0b4e91)
@felixfontein
Copy link
Collaborator

@salmon111 thanks a lot for fixing this!
@russoz thanks for reviewing!

Copy link

patchback bot commented Oct 28, 2024

Backport to stable-8: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-8/d0b4e91cac95b2b3c0984704799b1f1f2d4ce8b8/pr-9052

Backported as #9070

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Oct 28, 2024
…9052)

* modprobe: fix --check mode not being honored for persistent option

* Add CHANGELOG

* Update CHANGELOG

* Update changelogs/fragments/9052-modprobe-bugfix.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: d-usuba <d-usuba@sakura.ad.jp>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit d0b4e91)
Copy link

patchback bot commented Oct 28, 2024

Backport to stable-9: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-9/d0b4e91cac95b2b3c0984704799b1f1f2d4ce8b8/pr-9052

Backported as #9071

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Oct 28, 2024
…9052)

* modprobe: fix --check mode not being honored for persistent option

* Add CHANGELOG

* Update CHANGELOG

* Update changelogs/fragments/9052-modprobe-bugfix.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: d-usuba <d-usuba@sakura.ad.jp>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit d0b4e91)
felixfontein pushed a commit that referenced this pull request Oct 28, 2024
… being honored for persistent option (#9070)

modprobe: fix --check mode not being honored for persistent option (#9052)

* modprobe: fix --check mode not being honored for persistent option

* Add CHANGELOG

* Update CHANGELOG

* Update changelogs/fragments/9052-modprobe-bugfix.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: d-usuba <d-usuba@sakura.ad.jp>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit d0b4e91)

Co-authored-by: salmon111 <campfire@kumachans.net>
felixfontein pushed a commit that referenced this pull request Oct 28, 2024
… being honored for persistent option (#9071)

modprobe: fix --check mode not being honored for persistent option (#9052)

* modprobe: fix --check mode not being honored for persistent option

* Add CHANGELOG

* Update CHANGELOG

* Update changelogs/fragments/9052-modprobe-bugfix.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: d-usuba <d-usuba@sakura.ad.jp>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit d0b4e91)

Co-authored-by: salmon111 <campfire@kumachans.net>
@salmon111 salmon111 deleted the fix/modprobe-checkmode-persistent-bug branch October 29, 2024 02:28
felixfontein pushed a commit that referenced this pull request Oct 29, 2024
… being honored for persistent option (#9069)

modprobe: fix --check mode not being honored for persistent option (#9052)

* modprobe: fix --check mode not being honored for persistent option

* Add CHANGELOG

* Update CHANGELOG

* Update changelogs/fragments/9052-modprobe-bugfix.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: d-usuba <d-usuba@sakura.ad.jp>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit d0b4e91)

Co-authored-by: salmon111 <campfire@kumachans.net>
Massl123 pushed a commit to Massl123/community.general that referenced this pull request Feb 7, 2025
…nsible-collections#9052)

* modprobe: fix --check mode not being honored for persistent option

* Add CHANGELOG

* Update CHANGELOG

* Update changelogs/fragments/9052-modprobe-bugfix.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: d-usuba <d-usuba@sakura.ad.jp>
Co-authored-by: Felix Fontein <felix@fontein.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8 Automatically create a backport for the stable-8 branch backport-9 Automatically create a backport for the stable-9 branch bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

modprobe Ignores "--check" Mode When Using "persistent:" Option
5 participants