mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-04 15:29:10 -07:00
Fix alternatives module (#4836)
* Only pass subcommands when they are specified as module arguments. * When 'subcommands' is specified, 'link' must be given for every subcommand. * Extend subcommand tests.
This commit is contained in:
parent
a45b90e93f
commit
84d8ca9234
7 changed files with 151 additions and 3 deletions
|
@ -77,6 +77,7 @@ options:
|
|||
description:
|
||||
- The path to the symbolic link that should point to the real subcommand executable.
|
||||
type: path
|
||||
required: true
|
||||
version_added: 5.1.0
|
||||
requirements: [ update-alternatives ]
|
||||
'''
|
||||
|
@ -204,7 +205,7 @@ class AlternativesModule(object):
|
|||
|
||||
cmd = [self.UPDATE_ALTERNATIVES, '--install', self.link, self.name, self.path, str(self.priority)]
|
||||
|
||||
if self.subcommands is not None:
|
||||
if self.module.params['subcommands'] is not None:
|
||||
subcommands = [['--slave', subcmd['link'], subcmd['name'], subcmd['path']] for subcmd in self.subcommands]
|
||||
cmd += [item for sublist in subcommands for item in sublist]
|
||||
|
||||
|
@ -384,7 +385,7 @@ def main():
|
|||
subcommands=dict(type='list', elements='dict', aliases=['slaves'], options=dict(
|
||||
name=dict(type='str', required=True),
|
||||
path=dict(type='path', required=True),
|
||||
link=dict(type='path'),
|
||||
link=dict(type='path', required=True),
|
||||
)),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue