yum: Add option for enable and disable plugin (#34306)

This fix adds parameter to enable and disable plugins for yum
command.

Fixes: #30016

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/32363/merge
Abhijeet Kasurde 7 years ago committed by Martin Krizek
parent 158cd59994
commit d1b63bd5ef

@ -127,6 +127,18 @@ options:
type: bool type: bool
default: "no" default: "no"
version_added: "2.4" version_added: "2.4"
enable_plugin:
description:
- I(Plugin) name to enable for the install/update operation.
The enabled plugin will not persist beyond the transaction.
required: false
version_added: "2.5"
disable_plugin:
description:
- I(Plugin) name to disable for the install/update operation.
The disabled plugins will not persist beyond the transaction.
required: false
version_added: "2.5"
notes: notes:
- When used with a `loop:` each package will be processed individually, - When used with a `loop:` each package will be processed individually,
it is much more efficient to pass the list directly to the `name` option. it is much more efficient to pass the list directly to the `name` option.
@ -1149,7 +1161,7 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, up
def ensure(module, state, pkgs, conf_file, enablerepo, disablerepo, def ensure(module, state, pkgs, conf_file, enablerepo, disablerepo,
disable_gpg_check, exclude, repoq, skip_broken, update_only, security, disable_gpg_check, exclude, repoq, skip_broken, update_only, security,
installroot='/', allow_downgrade=False): installroot='/', allow_downgrade=False, disable_plugin='', enable_plugin=''):
# fedora will redirect yum to dnf, which has incompatibilities # fedora will redirect yum to dnf, which has incompatibilities
# with how this module expects yum to operate. If yum-deprecated # with how this module expects yum to operate. If yum-deprecated
@ -1182,6 +1194,12 @@ def ensure(module, state, pkgs, conf_file, enablerepo, disablerepo,
r_cmd = ['--enablerepo=%s' % enablerepo] r_cmd = ['--enablerepo=%s' % enablerepo]
yum_basecmd.extend(r_cmd) yum_basecmd.extend(r_cmd)
if enable_plugin:
yum_basecmd.extend(['--enableplugin', enable_plugin])
if disable_plugin:
yum_basecmd.extend(['--disableplugin', disable_plugin])
if exclude: if exclude:
e_cmd = ['--exclude=%s' % exclude] e_cmd = ['--exclude=%s' % exclude]
yum_basecmd.extend(e_cmd) yum_basecmd.extend(e_cmd)
@ -1291,6 +1309,8 @@ def main():
install_repoquery=dict(type='bool', default=True), install_repoquery=dict(type='bool', default=True),
allow_downgrade=dict(type='bool', default=False), allow_downgrade=dict(type='bool', default=False),
security=dict(type='bool', default=False), security=dict(type='bool', default=False),
enable_plugin=dict(type='list', default=[]),
disable_plugin=dict(type='list', default=[]),
), ),
required_one_of=[['name', 'list']], required_one_of=[['name', 'list']],
mutually_exclusive=[['name', 'list']], mutually_exclusive=[['name', 'list']],
@ -1307,6 +1327,12 @@ def main():
module.fail_json(msg='. '.join(error_msgs)) module.fail_json(msg='. '.join(error_msgs))
params = module.params params = module.params
enable_plugin = params.get('enable_plugin', '')
if enable_plugin:
enable_plugin = ','.join(enable_plugin)
disable_plugin = params.get('disable_plugin', '')
if disable_plugin:
disable_plugin = ','.join(disable_plugin)
if params['list']: if params['list']:
repoquerybin = ensure_yum_utils(module) repoquerybin = ensure_yum_utils(module)
@ -1349,7 +1375,8 @@ def main():
allow_downgrade = params['allow_downgrade'] allow_downgrade = params['allow_downgrade']
results = ensure(module, state, pkg, params['conf_file'], enablerepo, results = ensure(module, state, pkg, params['conf_file'], enablerepo,
disablerepo, disable_gpg_check, exclude, repoquery, disablerepo, disable_gpg_check, exclude, repoquery,
skip_broken, update_only, security, params['installroot'], allow_downgrade) skip_broken, update_only, security, params['installroot'], allow_downgrade,
disable_plugin=disable_plugin, enable_plugin=enable_plugin)
if repoquery: if repoquery:
results['msg'] = '%s %s' % ( results['msg'] = '%s %s' % (
results.get('msg', ''), results.get('msg', ''),

Loading…
Cancel
Save