mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -07:00
* alternatives: Fix bug with priority default
If neigther the priority nor the subcommands where specified the module decided to update the priority with the default value anyway. This resulted in bug #4803 and #4804
* Add changelog fragment.
* Distinguish None from 0.
* Address review comments.
* Update plugins/modules/system/alternatives.py
Co-authored-by: Pilou <pierre-louis@libregerbil.fr>
* Remove unrelated issues from changelog.
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Pilou <pierre-louis@libregerbil.fr>
(cherry picked from commit 57e83ac80b
)
Co-authored-by: Marius Rieder <marius.rieder@durchmesser.ch>
This commit is contained in:
parent
2f87b8c63f
commit
4275bfe87b
4 changed files with 26 additions and 7 deletions
|
@ -40,9 +40,8 @@ options:
|
|||
type: path
|
||||
priority:
|
||||
description:
|
||||
- The priority of the alternative.
|
||||
- The priority of the alternative. If no priority is given for creation C(50) is used as a fallback.
|
||||
type: int
|
||||
default: 50
|
||||
state:
|
||||
description:
|
||||
- C(present) - install the alternative (if not already installed), but do
|
||||
|
@ -171,9 +170,10 @@ class AlternativesModule(object):
|
|||
if self.mode_present:
|
||||
# Check if we need to (re)install
|
||||
subcommands_parameter = self.module.params['subcommands']
|
||||
priority_parameter = self.module.params['priority']
|
||||
if (
|
||||
self.path not in self.current_alternatives or
|
||||
self.current_alternatives[self.path].get('priority') != self.priority or
|
||||
(priority_parameter is not None and self.current_alternatives[self.path].get('priority') != priority_parameter) or
|
||||
(subcommands_parameter is not None and (
|
||||
not all(s in subcommands_parameter for s in self.current_alternatives[self.path].get('subcommands')) or
|
||||
not all(s in self.current_alternatives[self.path].get('subcommands') for s in subcommands_parameter)
|
||||
|
@ -273,7 +273,9 @@ class AlternativesModule(object):
|
|||
|
||||
@property
|
||||
def priority(self):
|
||||
return self.module.params.get('priority')
|
||||
if self.module.params.get('priority') is not None:
|
||||
return self.module.params.get('priority')
|
||||
return self.current_alternatives.get(self.path, {}).get('priority', 50)
|
||||
|
||||
@property
|
||||
def subcommands(self):
|
||||
|
@ -373,7 +375,7 @@ def main():
|
|||
name=dict(type='str', required=True),
|
||||
path=dict(type='path', required=True),
|
||||
link=dict(type='path'),
|
||||
priority=dict(type='int', default=50),
|
||||
priority=dict(type='int'),
|
||||
state=dict(
|
||||
type='str',
|
||||
choices=AlternativeState.to_list(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue