Open gotmax23 opened 2 years ago
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
cc @AnderEnder @alxgu @andytom @commel @dcermak @evrardjp @lrupp @sealor @toabctl click here for bot help
I've been looking for issues that I can tackle for Hacktoberfest and this looks interesting. I've been reading other modules to better understand how they acheive the desired effect and I think it's mostly replicable for zypper
.
My only concern is if zypper refresh
will return enough useful information to determine if the repositories have actually been updated. From my testing, it looks like there's no useful info returned to parse because we pass the --quiet
flag:
$ zypper clean -a
$ zypper --quiet --non-interactive --xmlout refresh
<?xml version='1.0'?>
<stream>
</stream>
It looks like we'd need to refactor some of the helper functions in the module in order to determine if any repos were actually updated during the run.
With this in mind, I'm going to put together a PR that returns with changed: True
if the refresh was merely sucessful (similarly to the approach used by the command
module which returns changed: True
by default)
With this in mind, I'm going to put together a PR that returns with
changed: True
if the refresh was merely sucessful (similarly to the approach used by thecommand
module which returnschanged: True
by default)
Do the other package modules behave like this or are some of them able to figure out if the contents of the repository actually changed? I haven't had a chance to look at this myself.
I haven't has a chance to look at all of the other package modules yet but from what I recall in my personal use, other package modules know when the repository data has actually been refreshed.
It's not impossible to tell with zypper
. If we remove the --quiet
flag, we'll see some <progress ..>
tags in the xml data it returns telling us if repositories were already up to date or if it tried downloading and building the latest data.
The helper functions that process the returned xml would need changes and that'd require testing all of the other supported use cases to avoid regressions. I'm not really a OpenSuse user so I thought I should probably keep my changes small/conservitive for now and maybe work on the bigger change later.
Okay, that makes sense. Thank you for working on this issue!
I haven't has a chance to look at all of the other package modules yet but from what I recall in my personal use, other package modules know when the repository data has actually been refreshed.
I was curious, so I tested it myself. All of the package modules I mentioned above besides community.general.pacman
and possibly community.general.apk
(I haven't tested that) support this. I look forward to your PR being accepted!
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
I was looking for something else, like using zypper clean --all
via a native Ansible way when I came across this feature request.
Why add this to zypper
when you can use zypper_repository
? I'm playing devils advocate here, but you can do this using something like:
- name: Building Zypper Cache...
community.general.zypper_repository:
repo: '*'
runrefresh: true
auto_import_keys: true
While YUM has the yum_repository
module for managing repos and Apt has the apt_repository
module, Zypper has zypper_repository
.
I agree on this. With apt one use the apt_repository module, this should be handle with zypper similarly.
Summary
Currently, it is not possible to update the package cache with the
community.general.zypper
module without specifying thename
argument.This task fails with the following error message:
This usecase is supported by every other distro package module (or at least the ones I've used). This includes
apt
,yum
,dnf
,pacman
, andapk
.This missing feature makes updating the package cache in my gotmax23.update role unnecessarily complicated.
-- https://git.sr.ht/~gotmax23/ansible-role-update/tree/d3ef47593f85fb917e6cc71833970f03994bf5ab/item/tasks/main.yml
Issue Type
Feature Idea
Component Name
plugins/modules/packaging/os/zypper.py
Additional Information
The example playbook below does not work.
Code of Conduct