-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[master] Update pkg.group_installed state to support repo options #64349
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Update `pkg.group_installed` state to support repo options |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ | |
import os | ||
import re | ||
|
||
import salt.utils.args | ||
import salt.utils.pkg | ||
import salt.utils.platform | ||
import salt.utils.versions | ||
|
@@ -257,7 +258,7 @@ def _find_download_targets( | |
normalize=True, | ||
skip_suggestions=False, | ||
ignore_epoch=None, | ||
**kwargs | ||
**kwargs, | ||
): | ||
""" | ||
Inspect the arguments to pkg.downloaded and discover what packages need to | ||
|
@@ -512,7 +513,7 @@ def _find_install_targets( | |
ignore_epoch=None, | ||
reinstall=False, | ||
refresh=False, | ||
**kwargs | ||
**kwargs, | ||
): | ||
""" | ||
Inspect the arguments to pkg.installed and discover what packages need to | ||
|
@@ -799,7 +800,7 @@ def _find_install_targets( | |
package_name, | ||
ignore_types=ignore_types, | ||
verify_options=verify_options, | ||
**kwargs | ||
**kwargs, | ||
) | ||
except (CommandExecutionError, SaltInvocationError) as exc: | ||
failed_verify = exc.strerror | ||
|
@@ -833,7 +834,7 @@ def _find_install_targets( | |
package_name, | ||
ignore_types=ignore_types, | ||
verify_options=verify_options, | ||
**kwargs | ||
**kwargs, | ||
) | ||
except (CommandExecutionError, SaltInvocationError) as exc: | ||
failed_verify = exc.strerror | ||
|
@@ -1061,7 +1062,7 @@ def installed( | |
ignore_epoch=None, | ||
reinstall=False, | ||
update_holds=False, | ||
**kwargs | ||
**kwargs, | ||
): | ||
""" | ||
.. versionchanged:: 3007.0 | ||
|
@@ -1769,7 +1770,7 @@ def installed( | |
ignore_epoch=ignore_epoch, | ||
reinstall=reinstall, | ||
refresh=refresh, | ||
**kwargs | ||
**kwargs, | ||
) | ||
|
||
try: | ||
|
@@ -1938,7 +1939,7 @@ def installed( | |
update_holds=update_holds, | ||
ignore_epoch=ignore_epoch, | ||
split_arch=False, | ||
**kwargs | ||
**kwargs, | ||
) | ||
except CommandExecutionError as exc: | ||
ret = {"name": name, "result": False} | ||
|
@@ -2155,7 +2156,7 @@ def installed( | |
reinstall_pkg, | ||
ignore_types=ignore_types, | ||
verify_options=verify_options, | ||
**kwargs | ||
**kwargs, | ||
) | ||
if verify_result: | ||
failed.append(reinstall_pkg) | ||
|
@@ -2344,7 +2345,7 @@ def downloaded( | |
downloadonly=True, | ||
fromrepo=fromrepo, | ||
ignore_epoch=ignore_epoch, | ||
**kwargs | ||
**kwargs, | ||
) | ||
ret["result"] = True | ||
ret["changes"].update(pkg_ret) | ||
|
@@ -2518,7 +2519,7 @@ def latest( | |
skip_verify=False, | ||
pkgs=None, | ||
watch_flags=True, | ||
**kwargs | ||
**kwargs, | ||
): | ||
""" | ||
.. versionchanged:: 3007.0 | ||
|
@@ -2829,7 +2830,7 @@ def latest( | |
fromrepo=fromrepo, | ||
skip_verify=skip_verify, | ||
pkgs=targeted_pkgs, | ||
**kwargs | ||
**kwargs, | ||
) | ||
except CommandExecutionError as exc: | ||
return { | ||
|
@@ -2937,7 +2938,7 @@ def _uninstall( | |
pkgs=None, | ||
normalize=True, | ||
ignore_epoch=None, | ||
**kwargs | ||
**kwargs, | ||
): | ||
""" | ||
Common function for package removal | ||
|
@@ -3001,7 +3002,6 @@ def _uninstall( | |
} | ||
|
||
if __opts__["test"]: | ||
|
||
_changes = {} | ||
_changes.update({x: {"new": "{}d".format(action), "old": ""} for x in targets}) | ||
|
||
|
@@ -3144,7 +3144,7 @@ def removed(name, version=None, pkgs=None, normalize=True, ignore_epoch=None, ** | |
pkgs=pkgs, | ||
normalize=normalize, | ||
ignore_epoch=ignore_epoch, | ||
**kwargs | ||
**kwargs, | ||
) | ||
except CommandExecutionError as exc: | ||
ret = {"name": name, "result": False} | ||
|
@@ -3236,7 +3236,7 @@ def purged(name, version=None, pkgs=None, normalize=True, ignore_epoch=None, **k | |
pkgs=pkgs, | ||
normalize=normalize, | ||
ignore_epoch=ignore_epoch, | ||
**kwargs | ||
**kwargs, | ||
) | ||
except CommandExecutionError as exc: | ||
ret = {"name": name, "result": False} | ||
|
@@ -3367,9 +3367,16 @@ def group_installed(name, skip=None, include=None, **kwargs): | |
.. versionchanged:: 2016.11.0 | ||
Added support in :mod:`pacman <salt.modules.pacman>` | ||
|
||
.. versionchanged:: 3006.2 | ||
For RPM-based systems, support for ``fromrepo``, ``enablerepo``, and | ||
``disablerepo`` (as used in :py:func:`pkg.install | ||
<salt.modules.yumpkg.install>`) has been added. This allows one to, for | ||
example, use ``enablerepo`` to perform a group install from a repo that | ||
is otherwise disabled. | ||
|
||
Ensure that an entire package group is installed. This state is currently | ||
only supported for the :mod:`yum <salt.modules.yumpkg>` and :mod:`pacman <salt.modules.pacman>` | ||
package managers. | ||
only supported for the :mod:`yum <salt.modules.yumpkg>` and :mod:`pacman | ||
<salt.modules.pacman>` package managers. | ||
|
||
skip | ||
Packages that would normally be installed by the package group | ||
|
@@ -3399,6 +3406,45 @@ def group_installed(name, skip=None, include=None, **kwargs): | |
This option can no longer be passed as a comma-separated list, it | ||
must now be passed as a list (as shown in the above example). | ||
|
||
.. note:: | ||
The below options are only supported on RPM-based systems | ||
|
||
fromrepo | ||
Restrict ``yum groupinfo`` to the specified repo(s). | ||
(e.g., ``yum --disablerepo='*' --enablerepo='somerepo'``) | ||
|
||
.. code-block:: yaml | ||
|
||
MyGroup: | ||
pkg.group_installed: | ||
- fromrepo: base,updates | ||
|
||
.. versionadded:: 3006.2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, if on https://github.com/saltstack/salt/pull/64349/files#r1210742029 we can reasonable say it's a bug, because of your argument, why is it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because support for these arguments needed to be added to make the code agree with the documentation: https://github.com/saltstack/salt/blob/c33b562/salt/states/pkg.py#L3402-L3406 Is it no longer considered a bug when the code doesn't do what the documentation says? I'm confused. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It is, of course. But can I argue that the function changed to accommodate the missing(and promised support) for the extra arguments? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think that has ever been in dispute. What seems to be in dispute though (unless I misunderstood your question), is whether adding arguments to a function to fix a bug makes the PR no longer a bugfix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was suggesting from Ignore my rant, I agree with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, yes, I definitely misunderstood your earlier comment (sorry about that). My thinking behind using I'm happy with whichever solution makes the docs make the most sense. |
||
|
||
enablerepo (ignored if ``fromrepo`` is specified) | ||
Specify a disabled package repository (or repositories) to enable. | ||
(e.g., ``yum --enablerepo='somerepo'``) | ||
|
||
.. code-block:: yaml | ||
|
||
MyGroup: | ||
pkg.group_installed: | ||
- enablerepo: myrepo | ||
|
||
.. versionadded:: 3006.2 | ||
|
||
disablerepo (ignored if ``fromrepo`` is specified) | ||
Specify an enabled package repository (or repositories) to disable. | ||
(e.g., ``yum --disablerepo='somerepo'``) | ||
|
||
.. code-block:: yaml | ||
|
||
MyGroup: | ||
pkg.group_installed: | ||
- disablerepo: epel | ||
|
||
.. versionadded:: 3006.2 | ||
|
||
.. note:: | ||
Because this is essentially a wrapper around :py:func:`pkg.install | ||
<salt.modules.yumpkg.install>`, any argument which can be passed to | ||
|
@@ -3432,13 +3478,16 @@ def group_installed(name, skip=None, include=None, **kwargs): | |
include[idx] = str(item) | ||
|
||
try: | ||
diff = __salt__["pkg.group_diff"](name) | ||
except CommandExecutionError as err: | ||
ret[ | ||
"comment" | ||
] = "An error was encountered while installing/updating group '{}': {}.".format( | ||
name, err | ||
diff = __salt__["pkg.group_diff"]( | ||
name, **salt.utils.args.clean_kwargs(**kwargs) | ||
) | ||
except (CommandExecutionError, TypeError) as err: | ||
if "unexpected keyword argument" in str(err): | ||
ret["comment"] = "Repo options are not supported on this platform" | ||
else: | ||
ret[ | ||
"comment" | ||
] = f"An error was encountered while installing/updating group '{name}': {err}." | ||
return ret | ||
|
||
mandatory = diff["mandatory"]["installed"] + diff["mandatory"]["not installed"] | ||
|
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.
This seems like its actually a feature, which resolves a bug so this would need to be
3007.0
, same for the 3006.2 references belowThere 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.
The documentation for the
pkgrepo.absent
state says that you can pass anything you would pass through to the execution module, which is not true. IMO, that's a bug. Promised functionality doesn't exist. This modification is in service of fixing that bug.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.
Sorry, had my other PR in mind, I meant
pkg.group_installed
, notpkgrepo.absent
.Here's the relevant block of code: https://github.com/saltstack/salt/blob/c33b562/salt/states/pkg.py#L3402-L3406