tested and verified yum enable/disablerepo option for yum module
This commit is contained in:
parent
368305a27d
commit
a876519f1f
1 changed files with 15 additions and 14 deletions
27
yum
27
yum
|
@ -139,7 +139,7 @@ def is_installed(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_
|
||||||
out += out2
|
out += out2
|
||||||
return [ p for p in out.split('\n') if p.strip() ]
|
return [ p for p in out.split('\n') if p.strip() ]
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg='Error from repoquery: %s' % err + err2)
|
module.fail_json(msg='Error from repoquery: %s: %s' % (cmd, err + err2))
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -171,7 +171,8 @@ def is_available(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return [ p for p in out.split('\n') if p.strip() ]
|
return [ p for p in out.split('\n') if p.strip() ]
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg='Error from repoquery: %s' % err)
|
module.fail_json(msg='Error from repoquery: %s: %s' % (cmd, err + err2))
|
||||||
|
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ def is_update(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_rep
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return set([ p for p in out.split('\n') if p.strip() ])
|
return set([ p for p in out.split('\n') if p.strip() ])
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg='Error from repoquery: %s' % err)
|
module.fail_json(msg='Error from repoquery: %s: %s' % (cmd, err + err2))
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -254,7 +255,7 @@ def what_provides(module, repoq, req_spec, conf_file, qf=def_qf, en_repos=[], d
|
||||||
pkgs = is_installed(module, repoq, req_spec, conf_file, qf=qf)
|
pkgs = is_installed(module, repoq, req_spec, conf_file, qf=qf)
|
||||||
return pkgs
|
return pkgs
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg='Error from repoquery: %s' % err + err2)
|
module.fail_json(msg='Error from repoquery: %s: %s' % (cmd, err + err2))
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -365,7 +366,7 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
|
|
||||||
nvra = local_nvra(spec)
|
nvra = local_nvra(spec)
|
||||||
# look for them in the rpmdb
|
# look for them in the rpmdb
|
||||||
if is_installed(module, repoq, nvra, conf_file, en_repos, dis_repos):
|
if is_installed(module, repoq, nvra, conf_file, en_repos=en_repos, dis_repos=dis_repos):
|
||||||
# if they are there, skip it
|
# if they are there, skip it
|
||||||
continue
|
continue
|
||||||
pkg = spec
|
pkg = spec
|
||||||
|
@ -377,7 +378,7 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
# range requires or file-requires or pkgname :(
|
# range requires or file-requires or pkgname :(
|
||||||
else:
|
else:
|
||||||
# look up what pkgs provide this
|
# look up what pkgs provide this
|
||||||
pkglist = what_provides(module, repoq, spec, conf_file, en_repos, dis_repos)
|
pkglist = what_provides(module, repoq, spec, conf_file, en_repos=en_repos, dis_repos=dis_repos)
|
||||||
if not pkglist:
|
if not pkglist:
|
||||||
res['msg'] += "No Package matching '%s' found available, installed or updated" % spec
|
res['msg'] += "No Package matching '%s' found available, installed or updated" % spec
|
||||||
module.fail_json(**res)
|
module.fail_json(**res)
|
||||||
|
@ -387,7 +388,7 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
for this in pkglist:
|
for this in pkglist:
|
||||||
if is_installed(module, repoq, this, conf_file, en_repos, dis_repos):
|
if is_installed(module, repoq, this, conf_file, en_repos=en_repos, dis_repos=dis_repos):
|
||||||
found = True
|
found = True
|
||||||
res['results'].append('%s providing %s is already installed' % (this, spec))
|
res['results'].append('%s providing %s is already installed' % (this, spec))
|
||||||
break
|
break
|
||||||
|
@ -434,14 +435,14 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
pkg = spec
|
pkg = spec
|
||||||
# req or pkgname remove
|
# req or pkgname remove
|
||||||
else:
|
else:
|
||||||
pkglist = is_installed(module, repoq, spec, conf_file, en_repos, dis_repos)
|
pkglist = is_installed(module, repoq, spec, conf_file, en_repos=en_repos, dis_repos=dis_repos)
|
||||||
if not pkglist:
|
if not pkglist:
|
||||||
res['msg'] += "No Package matching '%s' found installed" % spec
|
res['msg'] += "No Package matching '%s' found installed" % spec
|
||||||
module.exit_json(**res)
|
module.exit_json(**res)
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
for this in pkglist:
|
for this in pkglist:
|
||||||
if is_installed(module, repoq, this, conf_file, en_repos, dis_repos):
|
if is_installed(module, repoq, this, conf_file, en_repos=en_repos, dis_repos=dis_repos):
|
||||||
found = True
|
found = True
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
|
@ -485,12 +486,12 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
pkg = spec
|
pkg = spec
|
||||||
# dep/pkgname - find it
|
# dep/pkgname - find it
|
||||||
else:
|
else:
|
||||||
if is_installed(module, repoq, spec, conf_file, en_repos, dis_repos):
|
if is_installed(module, repoq, spec, conf_file, en_repos=en_repos, dis_repos=dis_repos):
|
||||||
basecmd = 'update'
|
basecmd = 'update'
|
||||||
else:
|
else:
|
||||||
basecmd = 'install'
|
basecmd = 'install'
|
||||||
|
|
||||||
pkglist = what_provides(module, repoq, spec, conf_file, en_repos, dis_repos)
|
pkglist = what_provides(module, repoq, spec, conf_file, en_repos=en_repos, dis_repos=dis_repos)
|
||||||
if not pkglist:
|
if not pkglist:
|
||||||
res['msg'] += "No Package matching '%s' found available, installed or updated" % spec
|
res['msg'] += "No Package matching '%s' found available, installed or updated" % spec
|
||||||
res['failed']=True
|
res['failed']=True
|
||||||
|
@ -498,11 +499,11 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
|
|
||||||
nothing_to_do = True
|
nothing_to_do = True
|
||||||
for this in pkglist:
|
for this in pkglist:
|
||||||
if basecmd == 'install' and is_available(module, repoq, this, conf_file, en_repos, dis_repos):
|
if basecmd == 'install' and is_available(module, repoq, this, conf_file, en_repos=en_repos, dis_repos=dis_repos):
|
||||||
nothing_to_do = False
|
nothing_to_do = False
|
||||||
break
|
break
|
||||||
|
|
||||||
if basecmd == 'update' and is_update(module, repoq, this, conf_file, en_repos, dis_repos):
|
if basecmd == 'update' and is_update(module, repoq, this, conf_file, en_repos=en_repos, dis_repos=en_repos):
|
||||||
nothing_to_do = False
|
nothing_to_do = False
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue