-
Notifications
You must be signed in to change notification settings - Fork 1.7k
rpm_ostree_pkg: fails to set needs_reboot
correctly
#10009
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
Comments
This comment has been minimized.
This comment has been minimized.
Files identified in the description: If these files are incorrect, please update the |
The module uses the return message from the rpm-ostree command. If needs_reboot is set to ('pending' in |
needs_reboot
correctly
hi @millerthegorilla thanks for reporting. Would you be willing to try and fix the module code? We'd be happy to assist you in the journey. |
One question is whether the module actually needs fixing. I understand "Determine if machine needs a reboot to apply current changes." that it will inform you whether the changes made by the module require a reboot. If the module didn't do any changes (due to idempotency), there's no need to reboot. The return value was added in #9167 by @shios86, maybe they can say more about this? |
I did a simple check on the output of the command of One question that should be asked, is whether the module itself should run 2 different command for 1 task. What I could do, is implement another state called |
|
In that case, should |
No, why? It works as documented (though maybe the documentation can be improved to make clearer what exactly it does). |
|
Hi, I would have been happy to make the changes, but I would have suggested the need to use the needs_reboot flag. I would have made a pending in rpm-ostree db diff and set the needs reboot flag. The reason is because there are already codebases out there, including mine, that rely on the needs_reboot to trigger a reboot in a task that follows the rpm_ostree_package task. Idempotency in the case of package installation is a special case for rpm-ostree systems. There is no point in installing a package without a reboot. So if I run the task twice without reaching a reboot, for example in the case of some package installation failure, I would expect the code to reflect the continued need to reboot the system, even if no changes are made. |
In fact, thinking about it, the need to reboot is such an integral part of the process of installing a package that it could be suggested that the rpm_ostree_package module could handle the reboot itself, if a flag were set. In most of the use cases I have, it is the ansible.builtin.package module that is running the code, with rpm_ostree_package set by the variable A further issue exists in that some packages are necessary to reboot immediately, in order to configure them or access the newly available paths, and some packages can be left to install and are used later. If a reboot is initiated in every situation, this can lead to much longer running times. So, in order to use existing code bases that use the builtin |
I am guessing we are in different timezones, but if you would like me to make a proposed change then I can make a pull request, just let me know and I will make time. |
I did make a parameters for it, but when providing the flag for reboot, it cut the SSH connection (shutting down would close all connections), which would fail the playbook run. As I am not really familiar with ansible internals, I removed the parameters, and made it a simple As said above, the needs_reboot flag just check the output rpm-ostree, it does not go further. My use cases were very simple so I did not dig further, if you wish to make the change, feel free to do so. |
Ok, I will have a look. There is an existing reboot module which pauses the play until the reboot has completed, so I will take a look at using that or similar. |
This module should not reboot the system. That's what the reboot module is for. |
I disagree. I am currently having to make a pull request against the devsec.hardening codebase, simply because I cannot call into their code and reboot the machine when various hardening packages are installed. The Currently the So it is expected that the The change I propose is to set a fact that will allow the One cannot simply insert a reboot module into existing codebases that use the builtin package module without considerable effort as I have discovered whilst working with devsec.hardening (dev-sec/ansible-collection-hardening#864). |
An alternative would be to include in the rpm_ostree_pkg module a notify handler that could the user could then define a reboot handler for. However, to get it to work, one would also have to add a |
I'm still not really convinced that a package installation module should automatically reboot the machine. I don't have experience with such systems though, and don't know about the challenges. I'm pretty sure though that automatically rebooting is wrong (doing so optionally could be OK, maybe). My suggestion would be to start a discussion on the behavior for rpm_ostree_pkg on the Ansible forum. I'm also curious how similar package managers work. (Is nix similar here, for example? How is it done there? And what exactly are the challenges - is it impossible to modify config files once packages are installed without rebooting first? Or is it just that you can't start the service without rebooting first?) |
This would require every task that calls the package manager to be modified. Modules and action plugins cannot notify anything in playbooks/roles. There is nothing this collection can do about that (except amending the documentation of the module). |
I took the opportunity to learn how action plugins work and wrote an action plugin that calls the rpm_ostree_pkg module and the builtin.reboot, depending on parameters passed to the plugin from the task. https://gist.github.com/millerthegorilla/acedbc8c5a4eeea4beee9de42c0f29ea An example playbook: - name: Test action plugin
hosts: all
become: true
vars:
# ostree_reboot:
# always_reboot: True
# msg: "going down!"
# pre_reboot_delay: 10
# ansible_package_use: community.general.rpm_ostree_pkg
tasks:
- name: Install_package
community.general.rpm_ostree_pkg:
name: nmap
state: absent
reboot: true
register: output
- debug: var=output Both the This plugin works by dropping into the directory I think it solves the problem reasonably elegantly, and with separation of concerns, decoupling etc... Whether it should be pushed to the ansible_collections.community.general codebase is another question entirely, although, I think it would allow an rpm-ostree system addressed by ansible to function as expected. I haven't yet tested it against the devsec codebase, ie an existing codebase that uses |
Unfortunately it doesn't work, the package module uses module_loader, and so it only picks up the rpm_ostree_pkg module, not the action plugin. Normally, the module code would be removed to the action plugin, and so the action plugin would work. |
Ok, I think that perhaps the Given the point of custom action plugins, it would seem to be a sensible idea. |
So I have opened a feature request at ansible/ansible#85021 |
Uh oh!
There was an error while loading. Please reload this page.
Summary
It is expected that ansible tasks are idempotent. However, when running rpm_ostree_package to install already installed, but pending, packages, the
needs_reboot
is returned as false, when if there are pending packages, as listed byrpm-ostree db diff
theneeds_reboot
should be true.Issue Type
Bug Report
Component Name
rpm_ostree_pkg
Ansible Version
Community.general Version
Configuration
config...
OS / Environment
fedora silverblue 41 host addressing a stable coreos remote, on a raspberry pi4b.
Steps to Reproduce
on second run, without reboot of remote. rpm-ostree db diff on remote reveals a pending deployment.
needs_reboot is false, when it should be true.
Expected Results
clamav_packages_install.needs_reboot
should be trueActual Results
needs_reboot is false
Code of Conduct
The text was updated successfully, but these errors were encountered: