import uuid
 import yaml
 
+from apex.common import utils
+
 CACHE_JOURNAL = 'cache_journal.yaml'
 TMP_CACHE = '.cache'
 BUILD_ROOT = 'build'
         make_args = ['RELEASE={}'.format(version)]
     else:
         make_args = []
+    logging.info('Running make clean...')
+    try:
+        subprocess.check_call(['make', '-C', build_root, 'clean'])
+    except subprocess.CalledProcessError:
+        logging.error('Failure to make clean')
+        raise
     logging.info('Building targets: {}'.format(make_targets))
     try:
         output = subprocess.check_output(["make"] + make_args + ["-C",
     console.setLevel(log_level)
     console.setFormatter(logging.Formatter(formatter))
     logging.getLogger('').addHandler(console)
-    apex_root = os.path.split(os.getcwd())[0]
-    if 'apex/apex' in apex_root:
-        apex_root = os.path.split(apex_root)[0]
-    for root, dirs, files in os.walk(apex_root):
-        if BUILD_ROOT in dirs and 'apex/apex' not in root:
-            apex_root = root
-            break
+    # Since we only support building inside of git repo this should be fine
+    try:
+        apex_root = subprocess.check_output(
+            ['git', 'rev-parse', '--show-toplevel']).decode('utf-8').strip()
+    except subprocess.CalledProcessError:
+        logging.error("Must be in an Apex git repo to execute build")
+        raise
     apex_build_root = os.path.join(apex_root, BUILD_ROOT)
     if os.path.isdir(apex_build_root):
         cache_tmp_dir = os.path.join(apex_root, TMP_CACHE)
         raise ApexBuildException("Invalid path for apex root: {}.  Must be "
                                  "invoked from within Apex code directory.".
                                  format(apex_root))
+    dep_playbook = os.path.join(apex_root,
+                                'lib/ansible/playbooks/build_dependencies.yml')
+    utils.run_ansible(None, dep_playbook)
     unpack_cache(cache_tmp_dir, args.cache_dir)
     build(apex_build_root, args.build_version, args.iso, args.rpms)
     build_cache(cache_tmp_dir, args.cache_dir)
 
+++ /dev/null
-#!/bin/sh
-##############################################################################
-# Copyright (c) 2016 Dan Radez (Red Hat) and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-set -e
-rpm -q ansible || sudo yum -y install ansible
-ansible-playbook --become -i "localhost," -c local $DIR/../lib/ansible/playbooks/build_dependencies.yml -vvv
-make -C $DIR/../build clean
-python3 $DIR/../apex/build.py $@
 
 - Apex overcloud .rpm (opnfv-apex) - For nosdn and OpenDaylight Scenarios
 - Apex undercloud .rpm (opnfv-apex-undercloud)
 - Apex common .rpm (opnfv-apex-common)
-- build.sh - Builds the above artifacts
+- build.py - Builds the above artifacts
 - opnfv-deploy - Automatically deploys Target OPNFV System
 - opnfv-clean - Automatically resets a Target OPNFV Deployment
 - opnfv-util - Utility to connect to or debug Overcloud nodes + OpenDaylight