From 2111e5a85f8d0a894e1a7684c2e1a6d897091c9d Mon Sep 17 00:00:00 2001 From: Tim Rozet Date: Wed, 14 Feb 2018 13:12:39 -0500 Subject: Fixes python2 docutils req and also installs ansible For some reason we were requiring python2-docutils in to build our rpm instead of python34-docutils. Patch also includes some logic to install ansible. JIRA: APEX-515 Change-Id: I1b85e5b4b29f74f5ff5399296f24831c334c289c Signed-off-by: Tim Rozet --- apex/build.py | 1 + apex/common/utils.py | 18 ++++++++++++++++++ apex/deploy.py | 1 + 3 files changed, 20 insertions(+) (limited to 'apex') diff --git a/apex/build.py b/apex/build.py index 08f91abe..dff25ac8 100644 --- a/apex/build.py +++ b/apex/build.py @@ -225,6 +225,7 @@ def main(): console.setLevel(log_level) console.setFormatter(logging.Formatter(formatter)) logging.getLogger('').addHandler(console) + utils.install_ansible() # Since we only support building inside of git repo this should be fine try: apex_root = subprocess.check_output( diff --git a/apex/common/utils.py b/apex/common/utils.py index 13250a45..0328a3b5 100644 --- a/apex/common/utils.py +++ b/apex/common/utils.py @@ -8,6 +8,7 @@ ############################################################################## import datetime +import distro import json import logging import os @@ -192,3 +193,20 @@ def fetch_upstream_and_unpack(dest, url, targets): tar = tarfile.open(target_dest) tar.extractall(path=dest) tar.close() + + +def install_ansible(): + # we only install for CentOS/Fedora for now + dist = distro.id() + if 'centos' in dist: + pkg_mgr = 'yum' + elif 'fedora' in dist: + pkg_mgr = 'dnf' + else: + return + + # yum python module only exists for 2.x, so use subprocess + try: + subprocess.check_call([pkg_mgr, '-y', 'install', 'ansible']) + except subprocess.CalledProcessError: + logging.warning('Unable to install Ansible') diff --git a/apex/deploy.py b/apex/deploy.py index d2f7d50b..5171c5cd 100644 --- a/apex/deploy.py +++ b/apex/deploy.py @@ -234,6 +234,7 @@ def main(): console.setLevel(log_level) console.setFormatter(logging.Formatter(formatter)) logging.getLogger('').addHandler(console) + utils.install_ansible() validate_deploy_args(args) # Parse all settings deploy_settings = DeploySettings(args.deploy_settings_file) -- cgit 1.2.3-korg