mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Allow yum module to take a yaml list of package names and also ", " separated string-list (in addition to comma separated string-list)
This commit is contained in:
parent
efd2cc6089
commit
9133ae8c55
1 changed files with 8 additions and 13 deletions
|
@ -44,7 +44,7 @@ description:
|
||||||
options:
|
options:
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- "Package name, or package specifier with version, like C(name-1.0). When using state=latest, this can be '*' which means run: yum -y update. You can also pass a url or a local path to a rpm file."
|
- "Package name, or package specifier with version, like C(name-1.0). When using state=latest, this can be '*' which means run: yum -y update. You can also pass a url or a local path to a rpm file. To operate on several packages this can accept a comma separated list of packages or (as of 2.0) a list of packages."
|
||||||
required: true
|
required: true
|
||||||
default: null
|
default: null
|
||||||
aliases: []
|
aliases: []
|
||||||
|
@ -68,7 +68,7 @@ options:
|
||||||
version_added: "0.9"
|
version_added: "0.9"
|
||||||
default: null
|
default: null
|
||||||
aliases: []
|
aliases: []
|
||||||
|
|
||||||
disablerepo:
|
disablerepo:
|
||||||
description:
|
description:
|
||||||
- I(Repoid) of repositories to disable for the install/update operation.
|
- I(Repoid) of repositories to disable for the install/update operation.
|
||||||
|
@ -715,16 +715,12 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
|
|
||||||
module.exit_json(**res)
|
module.exit_json(**res)
|
||||||
|
|
||||||
def ensure(module, state, pkgspec, conf_file, enablerepo, disablerepo,
|
def ensure(module, state, pkgs, conf_file, enablerepo, disablerepo,
|
||||||
disable_gpg_check):
|
disable_gpg_check):
|
||||||
|
|
||||||
# take multiple args comma separated
|
|
||||||
items = pkgspec.split(',')
|
|
||||||
|
|
||||||
# need debug level 2 to get 'Nothing to do' for groupinstall.
|
# need debug level 2 to get 'Nothing to do' for groupinstall.
|
||||||
yum_basecmd = [yumbin, '-d', '2', '-y']
|
yum_basecmd = [yumbin, '-d', '2', '-y']
|
||||||
|
|
||||||
|
|
||||||
if not repoquery:
|
if not repoquery:
|
||||||
repoq = None
|
repoq = None
|
||||||
else:
|
else:
|
||||||
|
@ -745,7 +741,6 @@ def ensure(module, state, pkgspec, conf_file, enablerepo, disablerepo,
|
||||||
en_repos = enablerepo.split(',')
|
en_repos = enablerepo.split(',')
|
||||||
r_cmd = ['--enablerepo=%s' % enablerepo]
|
r_cmd = ['--enablerepo=%s' % enablerepo]
|
||||||
yum_basecmd.extend(r_cmd)
|
yum_basecmd.extend(r_cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if state in ['installed', 'present', 'latest']:
|
if state in ['installed', 'present', 'latest']:
|
||||||
|
@ -774,13 +769,13 @@ def ensure(module, state, pkgspec, conf_file, enablerepo, disablerepo,
|
||||||
if state in ['installed', 'present']:
|
if state in ['installed', 'present']:
|
||||||
if disable_gpg_check:
|
if disable_gpg_check:
|
||||||
yum_basecmd.append('--nogpgcheck')
|
yum_basecmd.append('--nogpgcheck')
|
||||||
install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
|
install(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
|
||||||
elif state in ['removed', 'absent']:
|
elif state in ['removed', 'absent']:
|
||||||
remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
|
remove(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
|
||||||
elif state == 'latest':
|
elif state == 'latest':
|
||||||
if disable_gpg_check:
|
if disable_gpg_check:
|
||||||
yum_basecmd.append('--nogpgcheck')
|
yum_basecmd.append('--nogpgcheck')
|
||||||
latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
|
latest(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
|
||||||
|
|
||||||
# should be caught by AnsibleModule argument_spec
|
# should be caught by AnsibleModule argument_spec
|
||||||
return dict(changed=False, failed=True, results='', errors='unexpected state')
|
return dict(changed=False, failed=True, results='', errors='unexpected state')
|
||||||
|
@ -800,7 +795,7 @@ def main():
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
name=dict(aliases=['pkg']),
|
name=dict(aliases=['pkg'], type="list"),
|
||||||
# removed==absent, installed==present, these are accepted as aliases
|
# removed==absent, installed==present, these are accepted as aliases
|
||||||
state=dict(default='installed', choices=['absent','present','installed','removed','latest']),
|
state=dict(default='installed', choices=['absent','present','installed','removed','latest']),
|
||||||
enablerepo=dict(),
|
enablerepo=dict(),
|
||||||
|
@ -829,7 +824,7 @@ def main():
|
||||||
module.exit_json(**results)
|
module.exit_json(**results)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
pkg = params['name']
|
pkg = [ p.strip() for p in params['name']]
|
||||||
state = params['state']
|
state = params['state']
|
||||||
enablerepo = params.get('enablerepo', '')
|
enablerepo = params.get('enablerepo', '')
|
||||||
disablerepo = params.get('disablerepo', '')
|
disablerepo = params.get('disablerepo', '')
|
||||||
|
|
Loading…
Reference in a new issue