-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
add persistent option for modprobe #5424
add persistent option for modprobe #5424
Conversation
Docs Build 📝Thank you for contribution!✨ The docsite for this PR is available for download as an artifact from this run: File changes:
Click to see the diff comparison.NOTE: only file modifications are shown here. New and deleted files are excluded. diff --git a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/modprobe_module.html b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/modprobe_module.html
index 9c6fcf8..3b348b9 100644
--- a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/modprobe_module.html
+++ b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/modprobe_module.html
@@ -177,6 +177,22 @@
</div></td>
</tr>
<tr class="row-even"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-persistent"></div><p class="ansible-option-title" id="ansible-collections-community-general-modprobe-module-parameter-persistent"><strong>persistent</strong></p>
+<a class="ansibleOptionLink" href="#parameter-persistent" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>Persistency between reboots for configured module.</p>
+<p>This option creates files in <code class="docutils literal notranslate"><span class="pre">/etc/modules-load.d/</span></code> and <code class="docutils literal notranslate"><span class="pre">/etc/modprobe.d/</span></code> that make your module configuration persistent during reboots.</p>
+<p>Note that it is usually a better idea to rely on the automatic module loading by PCI IDs, USB IDs, DMI IDs or similar triggers encoded in the kernel modules themselves instead of configuration like this.</p>
+<p>In fact, most modern kernel modules are prepared for automatic loading already.</p>
+<p>Also this options work only with distributives that uses systemd.</p>
+<p class="ansible-option-line"><span class="ansible-option-choices">Choices:</span></p>
+<ul class="simple">
+<li><p><code class="ansible-option-default-bold docutils literal notranslate"><span class="pre">false</span></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
+<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">true</span></code></p></li>
+</ul>
+</div></td>
+</tr>
+<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-state"></div><p class="ansible-option-title" id="ansible-collections-community-general-modprobe-module-parameter-state"><strong>state</strong></p>
<a class="ansibleOptionLink" href="#parameter-state" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
</div></td>
|
There was a problem hiding this 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! I've added some first comments.
Made all the suggested changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been looking at this PR for some time now, and I'm not sure whether this option (as a boolean toggle with a default value) is a good idea. How can you for example say "the module should be still loaded now, but not persistently anymore" with this toggle?
I first thought it might be better to update state
to have two more values, presistent
and not_persistent
, so that present
means "I don't care whether it is persistent", and absent
implies "not persistent", but then I know too little about this to be sure this is an accurate description of what can be done / makes sense. I guess you could declare a module as persistent without having it loaded now? (Which would not be possible with these states.) Also since persistent
has stronger requirements than the remainder of the module, coupling it to state=absent
is a big problem.
plugins/modules/system/modprobe.py
Outdated
- Note that it is usually a better idea to rely on the automatic module loading by PCI IDs, USB IDs, DMI IDs or similar triggers encoded in the | ||
kernel modules themselves instead of configuration like this. | ||
- In fact, most modern kernel modules are prepared for automatic loading already. | ||
- Also this options work only with distributives that uses systemd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Also this options work only with distributives that uses systemd. | |
- Also this options work only with distributions that uses systemd. |
Answering your first question - yes. That's the exact idea behind this feature. You need to set Second question - No, you cannot declare module as persistent without having it loaded now. As i already mentioned persistency is connected to state. You can just take a look at |
Please note that in #5461 the collection repository was restructured to remove the directory tree in plugins/modules/, and the corresponding tree in tests/unit/plugins/modules/. Your PR modifies files in this directory structure, and unfortunately now has some conflicts, potentially because of this. Please rebase with the current |
9b5e4d4
to
44f8647
Compare
Sorry that it took me so long, but I've made this rebase. |
This comment was marked as outdated.
This comment was marked as outdated.
Hi @felixfontein, can you please help me with understanding tests result: I don't quite get why this one test is failed. What should I change? |
@haddystuff please simply ignore it, it will fail until you rebase with current |
Thank you @felixfontein |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one small improvement when compiling the regexps, other than that it LGTM
- move regexps compiling to __init__ - move AnsibleModule to build_module function and use this function in tests instead of AnsibleModule - fix terminlogy issue in documentation
This comment was marked as outdated.
This comment was marked as outdated.
@felixfontein, all issues you and @russoz have mentioned are fixed |
There was a problem hiding this 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. I'll merge tomorrow evening if nobody objects.
Backport to stable-6: 💚 backport PR created✅ Backport PR branch: Backported as #6102 🤖 @patchback |
* add persistent option for modprobe * add suggested changes + fix broken test * change modprobe module path in tests due to rebase * change persistent option type from bool to str with choices * fix unused import * add example with persistent option * fix some minor issues after review - move regexps compiling to __init__ - move AnsibleModule to build_module function and use this function in tests instead of AnsibleModule - fix terminlogy issue in documentation * fix unused-import (cherry picked from commit 29f5033)
@haddystuff thanks for your contribution, and sorry it took so long to get this done! |
…robe (#6102) add persistent option for modprobe (#5424) * add persistent option for modprobe * add suggested changes + fix broken test * change modprobe module path in tests due to rebase * change persistent option type from bool to str with choices * fix unused import * add example with persistent option * fix some minor issues after review - move regexps compiling to __init__ - move AnsibleModule to build_module function and use this function in tests instead of AnsibleModule - fix terminlogy issue in documentation * fix unused-import (cherry picked from commit 29f5033) Co-authored-by: Alex Groshev <38885591+haddystuff@users.noreply.github.com>
SUMMARY
Add persistent option as was requested in #4028
ISSUE TYPE
COMPONENT NAME
plugins/modules/system/modprobe.py
ADDITIONAL INFORMATION
If kernel module doesn't load after reboot(by PCI IDs, USB IDs, DMI IDs or similar triggers) you can use static files in /etc/modules-load.d to load this module. This is what I implemented. If you add option permanent and set it as true ansible will add module file which should enable module on startup. If you set permanent option as false then ansible will try to find line where you enabled this module previously and comment it out. Same works with kernel module options in /etc/modprobe.d directory.
Example: