|
|
@ -290,24 +290,23 @@ def ensure_yum_utils(module):
|
|
|
|
|
|
|
|
|
|
|
|
def fetch_rpm_from_url(spec, module=None):
|
|
|
|
def fetch_rpm_from_url(spec, module=None):
|
|
|
|
# download package so that we can query it
|
|
|
|
# download package so that we can query it
|
|
|
|
tempdir = tempfile.mkdtemp()
|
|
|
|
package_name, _ = os.path.splitext(str(spec.rsplit('/', 1)[1]))
|
|
|
|
package = os.path.join(tempdir, str(spec.rsplit('/', 1)[1]))
|
|
|
|
package_file = tempfile.NamedTemporaryFile(prefix=package_name, suffix='.rpm', delete=False)
|
|
|
|
|
|
|
|
module.add_cleanup_file(package_file.name)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
rsp, info = fetch_url(module, spec)
|
|
|
|
rsp, info = fetch_url(module, spec)
|
|
|
|
if not rsp:
|
|
|
|
if not rsp:
|
|
|
|
module.fail_json(msg="Failure downloading %s, %s" % (spec, info['msg']))
|
|
|
|
module.fail_json(msg="Failure downloading %s, %s" % (spec, info['msg']))
|
|
|
|
f = open(package, 'w')
|
|
|
|
|
|
|
|
data = rsp.read(BUFSIZE)
|
|
|
|
data = rsp.read(BUFSIZE)
|
|
|
|
while data:
|
|
|
|
while data:
|
|
|
|
f.write(data)
|
|
|
|
package_file.write(data)
|
|
|
|
data = rsp.read(BUFSIZE)
|
|
|
|
data = rsp.read(BUFSIZE)
|
|
|
|
f.close()
|
|
|
|
package_file.close()
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
e = get_exception()
|
|
|
|
e = get_exception()
|
|
|
|
shutil.rmtree(tempdir)
|
|
|
|
|
|
|
|
if module:
|
|
|
|
if module:
|
|
|
|
module.fail_json(msg="Failure downloading %s, %s" % (spec, e))
|
|
|
|
module.fail_json(msg="Failure downloading %s, %s" % (spec, e))
|
|
|
|
return package
|
|
|
|
return package_file.name
|
|
|
|
|
|
|
|
|
|
|
|
def po_to_nevra(po):
|
|
|
|
def po_to_nevra(po):
|
|
|
|
|
|
|
|
|
|
|
@ -478,13 +477,6 @@ def what_provides(module, repoq, req_spec, conf_file, qf=def_qf, en_repos=None,
|
|
|
|
if dis_repos is None:
|
|
|
|
if dis_repos is None:
|
|
|
|
dis_repos = []
|
|
|
|
dis_repos = []
|
|
|
|
|
|
|
|
|
|
|
|
if req_spec.endswith('.rpm') and '://' not in req_spec:
|
|
|
|
|
|
|
|
return req_spec
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif '://' in req_spec:
|
|
|
|
|
|
|
|
local_path = fetch_rpm_from_url(req_spec, module=module)
|
|
|
|
|
|
|
|
return local_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not repoq:
|
|
|
|
if not repoq:
|
|
|
|
|
|
|
|
|
|
|
|
pkgs = []
|
|
|
|
pkgs = []
|
|
|
@ -655,7 +647,6 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, i
|
|
|
|
res['msg'] = ''
|
|
|
|
res['msg'] = ''
|
|
|
|
res['rc'] = 0
|
|
|
|
res['rc'] = 0
|
|
|
|
res['changed'] = False
|
|
|
|
res['changed'] = False
|
|
|
|
tempdir = tempfile.mkdtemp()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for spec in items:
|
|
|
|
for spec in items:
|
|
|
|
pkg = None
|
|
|
|
pkg = None
|
|
|
@ -754,13 +745,6 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, i
|
|
|
|
cmd = yum_basecmd + ['install'] + pkgs
|
|
|
|
cmd = yum_basecmd + ['install'] + pkgs
|
|
|
|
|
|
|
|
|
|
|
|
if module.check_mode:
|
|
|
|
if module.check_mode:
|
|
|
|
# Remove rpms downloaded for EL5 via url
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
shutil.rmtree(tempdir)
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
e = get_exception()
|
|
|
|
|
|
|
|
module.fail_json(msg="Failure deleting temp directory %s, %s" % (tempdir, e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exit_json(changed=True, results=res['results'], changes=dict(installed=pkgs))
|
|
|
|
module.exit_json(changed=True, results=res['results'], changes=dict(installed=pkgs))
|
|
|
|
|
|
|
|
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
@ -794,13 +778,6 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, i
|
|
|
|
# Record change
|
|
|
|
# Record change
|
|
|
|
res['changed'] = changed
|
|
|
|
res['changed'] = changed
|
|
|
|
|
|
|
|
|
|
|
|
# Remove rpms downloaded for EL5 via url
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
shutil.rmtree(tempdir)
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
e = get_exception()
|
|
|
|
|
|
|
|
module.fail_json(msg="Failure deleting temp directory %s, %s" % (tempdir, e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|