Merge pull request #3311 from kustodian/yum-fix-changed-in-check-mode
Yum module always downloads remote rpms. fixes #1452
This commit is contained in:
commit
0268864211
1 changed files with 33 additions and 19 deletions
|
@ -482,6 +482,19 @@ def local_nvra(module, path):
|
|||
header[rpm.RPMTAG_RELEASE],
|
||||
header[rpm.RPMTAG_ARCH])
|
||||
|
||||
def local_name(module, path):
|
||||
"""return package name of a local rpm passed in"""
|
||||
|
||||
ts = rpm.TransactionSet()
|
||||
ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
|
||||
fd = os.open(path, os.O_RDONLY)
|
||||
try:
|
||||
header = ts.hdrFromFdno(fd)
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
return header[rpm.RPMTAG_NAME]
|
||||
|
||||
def pkg_to_dict(pkgstr):
|
||||
|
||||
if pkgstr.strip():
|
||||
|
@ -556,34 +569,35 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
|||
res['msg'] += "No Package file matching '%s' found on system" % spec
|
||||
module.fail_json(**res)
|
||||
|
||||
nvra = local_nvra(module, spec)
|
||||
pkg_name = local_name(module, spec)
|
||||
# look for them in the rpmdb
|
||||
if is_installed(module, repoq, nvra, conf_file, en_repos=en_repos, dis_repos=dis_repos):
|
||||
if is_installed(module, repoq, pkg_name, conf_file, en_repos=en_repos, dis_repos=dis_repos):
|
||||
# if they are there, skip it
|
||||
continue
|
||||
pkg = spec
|
||||
|
||||
# URL
|
||||
elif '://' in spec:
|
||||
pkg = spec
|
||||
# Check if Enterprise Linux 5 or less, as yum on those versions do not support installing via url
|
||||
distribution_version = get_distribution_version()
|
||||
distribution = platform.dist()
|
||||
if distribution[0] == "redhat" and LooseVersion(distribution_version) < LooseVersion("6"):
|
||||
package = os.path.join(tempdir, str(pkg.rsplit('/', 1)[1]))
|
||||
# download package so that we can check if it's already installed
|
||||
package = os.path.join(tempdir, str(spec.rsplit('/', 1)[1]))
|
||||
try:
|
||||
rsp, info = fetch_url(module, pkg)
|
||||
rsp, info = fetch_url(module, spec)
|
||||
f = open(package, 'w')
|
||||
data = rsp.read(BUFSIZE)
|
||||
while data:
|
||||
f.write(data)
|
||||
data = rsp.read(BUFSIZE)
|
||||
f.close()
|
||||
pkg = package
|
||||
except Exception, e:
|
||||
shutil.rmtree(tempdir)
|
||||
module.fail_json(msg="Failure downloading %s, %s" % (spec, e))
|
||||
|
||||
pkg_name = local_name(module, package)
|
||||
if is_installed(module, repoq, pkg_name, conf_file, en_repos=en_repos, dis_repos=dis_repos):
|
||||
# if it's there, skip it
|
||||
continue
|
||||
pkg = package
|
||||
|
||||
#groups :(
|
||||
elif spec.startswith('@'):
|
||||
# complete wild ass guess b/c it's a group
|
||||
|
|
Loading…
Reference in a new issue