mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-12 00:54:22 -07:00
Teach the yum module to support --check mode.
This commit is contained in:
parent
4f249902b3
commit
18cbb64f25
1 changed files with 14 additions and 1 deletions
15
library/yum
15
library/yum
|
@ -416,6 +416,10 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
pkg = spec
|
pkg = spec
|
||||||
|
|
||||||
cmd = yum_basecmd + ['install', pkg]
|
cmd = yum_basecmd + ['install', pkg]
|
||||||
|
|
||||||
|
if module.check_mode:
|
||||||
|
module.exit_json(changed=True)
|
||||||
|
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
|
|
||||||
res['rc'] += rc
|
res['rc'] += rc
|
||||||
|
@ -451,6 +455,10 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
|
|
||||||
# run an actual yum transaction
|
# run an actual yum transaction
|
||||||
cmd = yum_basecmd + ["remove", pkg]
|
cmd = yum_basecmd + ["remove", pkg]
|
||||||
|
|
||||||
|
if module.check_mode:
|
||||||
|
module.exit_json(changed=True)
|
||||||
|
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
|
|
||||||
res['rc'] += rc
|
res['rc'] += rc
|
||||||
|
@ -520,6 +528,10 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
pkg = spec
|
pkg = spec
|
||||||
|
|
||||||
cmd = yum_basecmd + [basecmd, pkg]
|
cmd = yum_basecmd + [basecmd, pkg]
|
||||||
|
|
||||||
|
if module.check_mode:
|
||||||
|
return module.exit_json(changed=True)
|
||||||
|
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
|
|
||||||
res['rc'] += rc
|
res['rc'] += rc
|
||||||
|
@ -619,7 +631,8 @@ def main():
|
||||||
conf_file=dict(default=None),
|
conf_file=dict(default=None),
|
||||||
),
|
),
|
||||||
required_one_of = [['name','list']],
|
required_one_of = [['name','list']],
|
||||||
mutually_exclusive = [['name','list']]
|
mutually_exclusive = [['name','list']],
|
||||||
|
supports_check_mode = True
|
||||||
)
|
)
|
||||||
|
|
||||||
params = module.params
|
params = module.params
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue