Merge "Make ansible package check more robust"
This commit is contained in:
commit
3a6208f342
|
@ -236,6 +236,8 @@ class AnsibleManager:
|
||||||
result = False
|
result = False
|
||||||
try:
|
try:
|
||||||
extra_packages = self._getAnsible(version).extra_packages
|
extra_packages = self._getAnsible(version).extra_packages
|
||||||
|
if not extra_packages:
|
||||||
|
return True
|
||||||
|
|
||||||
# Formerly this used pkg_resources which has been deprecated. If
|
# Formerly this used pkg_resources which has been deprecated. If
|
||||||
# there is a better way to accomplish this task please change
|
# there is a better way to accomplish this task please change
|
||||||
|
@ -248,19 +250,21 @@ class AnsibleManager:
|
||||||
command += extra_packages
|
command += extra_packages
|
||||||
ret = subprocess.run(command,
|
ret = subprocess.run(command,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.PIPE)
|
||||||
|
if ret.stdout:
|
||||||
to_be_installed = json.loads(ret.stdout)["install"]
|
to_be_installed = json.loads(ret.stdout)["install"]
|
||||||
|
else:
|
||||||
|
to_be_installed = None
|
||||||
# We check manually so that we can log the missing packages
|
# We check manually so that we can log the missing packages
|
||||||
# properly. We also need to check the the JSON output to determine
|
# properly. We also need to check the the JSON output to determine
|
||||||
# if any changes were necessary.
|
# if any changes were necessary.
|
||||||
if to_be_installed:
|
if to_be_installed:
|
||||||
self.log.error(
|
|
||||||
'Ansible version %s installation is missing packages' %
|
|
||||||
version)
|
|
||||||
missing = ["%s %s" %
|
missing = ["%s %s" %
|
||||||
(x["metadata"]["name"], x["metadata"]["version"])
|
(x["metadata"]["name"], x["metadata"]["version"])
|
||||||
for x in to_be_installed]
|
for x in to_be_installed]
|
||||||
self.log.debug("These packages are missing: %s", missing)
|
self.log.error(
|
||||||
|
'Ansible version %s installation is missing packages %s',
|
||||||
|
version, missing)
|
||||||
else:
|
else:
|
||||||
result = True
|
result = True
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in New Issue