@ -35,7 +35,6 @@ def is_installed(repoq, pkgspec, qf=def_qf):
rc,out,err = run(cmd)
rc,out,err = run(cmd)
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() ]
return []
return []
def is_available(repoq, pkgspec, qf=def_qf):
def is_available(repoq, pkgspec, qf=def_qf):
@ -43,10 +42,8 @@ def is_available(repoq, pkgspec, qf=def_qf):
rc,out,err = run(cmd)
rc,out,err = run(cmd)
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() ]
return []
return []
def is_update(repoq, pkgspec, qf=def_qf):
def is_update(repoq, pkgspec, qf=def_qf):
cmd = repoq + ["--pkgnarrow=updates", "--qf", qf, pkgspec]
cmd = repoq + ["--pkgnarrow=updates", "--qf", qf, pkgspec]
rc,out,err = run(cmd)
rc,out,err = run(cmd)
@ -55,17 +52,14 @@ def is_update(repoq, pkgspec, qf=def_qf):
return []
return []
def what_provides(repoq, req_spec, qf=def_qf):
def what_provides(repoq, req_spec, qf=def_qf):
cmd = repoq + ["--qf", qf, "--whatprovides", req_spec]
cmd = repoq + ["--qf", qf, "--whatprovides", req_spec]
rc,out,err = run(cmd)
rc,out,err = run(cmd)
ret = []
ret = []
if rc == 0:
if rc == 0:
ret = set([ p for p in out.split('\n') if p.strip() ])
ret = set([ p for p in out.split('\n') if p.strip() ])
return ret
return ret
def pkg_to_dict(pkgstr):
def pkg_to_dict(pkgstr):
if pkgstr.strip():
if pkgstr.strip():
n,e,v,r,a,repo = pkgstr.split('|')
n,e,v,r,a,repo = pkgstr.split('|')
@ -95,7 +89,6 @@ def repolist(repoq, qf="%{repoid}"):
ret = []
ret = []
if rc == 0:
if rc == 0:
ret = set([ p for p in out.split('\n') if p.strip() ])
ret = set([ p for p in out.split('\n') if p.strip() ])
return ret
return ret
def list_stuff(conf_file, stuff):
def list_stuff(conf_file, stuff):
@ -128,7 +121,6 @@ def run(command):
rc = 1
rc = 1
err = traceback.format_exc()
err = traceback.format_exc()
out = ''
out = ''
if out is None:
if out is None:
out = ''
out = ''
if err is None:
if err is None:
@ -429,15 +421,13 @@ def main():
state=dict(default='installed', choices=['absent','present','installed','removed','latest']),
state=dict(default='installed', choices=['absent','present','installed','removed','latest']),
list=dict(),
list=dict(),
conf_file=dict(default=None),
conf_file=dict(default=None),
)
),
required_one_of = [['pkg','list']],
mutually_exclusive = [['pkg','list']]
)
)
params = module.params
params = module.params
if params['list'] and params['pkg']:
module.fail_json(msg="expected 'list=' or 'name=', but not both")
if params['list']:
if params['list']:
if not os.path.exists(repoquery):
if not os.path.exists(repoquery):
module.fail_json(msg="%s is required to use list= with this module. Please install the yum-utils package." % repoquery)
module.fail_json(msg="%s is required to use list= with this module. Please install the yum-utils package." % repoquery)
@ -446,9 +436,6 @@ def main():
else:
else:
pkg = params['pkg']
pkg = params['pkg']
if pkg is None:
module.fail_json(msg="expected 'list=' or 'name='")
else:
state = params['state']
state = params['state']
res = ensure(module, state, pkg, params['conf_file'])
res = ensure(module, state, pkg, params['conf_file'])
module.fail_json(msg="we should never get here unless this all failed", **res)
module.fail_json(msg="we should never get here unless this all failed", **res)