summaryrefslogtreecommitdiffstats
path: root/apex/common
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2018-02-14 13:12:39 -0500
committerTim Rozet <trozet@redhat.com>2018-02-15 12:00:05 -0500
commit2111e5a85f8d0a894e1a7684c2e1a6d897091c9d (patch)
tree02b929082ab790d524696a08cd1102814a9e92f8 /apex/common
parent1f6ee5a99cb191afde06695e449c53732453b222 (diff)
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 <trozet@redhat.com>
Diffstat (limited to 'apex/common')
-rw-r--r--apex/common/utils.py18
1 files changed, 18 insertions, 0 deletions
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')