Merge pull request #1408 from Jmainguy/yum_http_el5
forces EL5 to fail if name=:// url style path to rpm
This commit is contained in:
commit
00e54793a2
1 changed files with 32 additions and 0 deletions
|
@ -27,6 +27,11 @@ import os
|
||||||
import yum
|
import yum
|
||||||
import rpm
|
import rpm
|
||||||
import syslog
|
import syslog
|
||||||
|
import platform
|
||||||
|
import tempfile
|
||||||
|
import shutil
|
||||||
|
from ansible.module_utils.urls import *
|
||||||
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from yum.misc import find_unfinished_transactions, find_ts_remaining
|
from yum.misc import find_unfinished_transactions, find_ts_remaining
|
||||||
|
@ -486,6 +491,7 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
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
|
||||||
|
@ -508,6 +514,21 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
# URL
|
# URL
|
||||||
elif '://' in spec:
|
elif '://' in spec:
|
||||||
pkg = 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]))
|
||||||
|
try:
|
||||||
|
rsp, info = fetch_url(module, pkg)
|
||||||
|
data = rsp.read()
|
||||||
|
f = open(package, 'w')
|
||||||
|
f.write(data)
|
||||||
|
f.close()
|
||||||
|
pkg = package
|
||||||
|
except Exception, e:
|
||||||
|
shutil.rmtree(tempdir)
|
||||||
|
module.fail_json(msg="Failure downloading %s, %s" % (spec, e))
|
||||||
|
|
||||||
#groups :(
|
#groups :(
|
||||||
elif spec.startswith('@'):
|
elif spec.startswith('@'):
|
||||||
|
@ -569,6 +590,11 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
cmd = yum_basecmd + ['install', pkg]
|
cmd = yum_basecmd + ['install', pkg]
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
|
# Remove rpms downloaded for EL5 via url
|
||||||
|
try:
|
||||||
|
shutil.rmtree(tempdir)
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg="Failure deleting temp directory %s, %s" % (tempdir, e))
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
|
||||||
changed = True
|
changed = True
|
||||||
|
@ -600,6 +626,12 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
# accumulate any changes
|
# accumulate any changes
|
||||||
res['changed'] |= changed
|
res['changed'] |= changed
|
||||||
|
|
||||||
|
# Remove rpms downloaded for EL5 via url
|
||||||
|
try:
|
||||||
|
shutil.rmtree(tempdir)
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg="Failure deleting temp directory %s, %s" % (tempdir, e))
|
||||||
|
|
||||||
module.exit_json(**res)
|
module.exit_json(**res)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue