Fix to use awx/lib/site-packages for all tasks, avoid using amqp broker for unit tests.

This commit is contained in:
Chris Church
2013-12-11 10:45:54 -05:00
parent c850379222
commit 4abb595a1f
2 changed files with 10 additions and 6 deletions

View File

@@ -125,6 +125,12 @@ class BaseTask(Task):
# Set environment variables needed for inventory and job event
# callbacks to work.
env['ANSIBLE_NOCOLOR'] = '1' # Prevent output of escape sequences.
# Update PYTHONPATH to use local site-packages.
python_paths = env.get('PYTHONPATH', '').split(os.pathsep)
local_site_packages = self.get_path_to('..', 'lib', 'site-packages')
if local_site_packages not in python_paths:
python_paths.insert(0, local_site_packages)
env['PYTHONPATH'] = os.pathsep.join(python_paths)
return env
def build_safe_env(self, instance, **kwargs):
@@ -799,12 +805,6 @@ class RunInventoryUpdate(BaseTask):
Build environment dictionary for inventory import.
'''
env = super(RunInventoryUpdate, self).build_env(inventory_update, **kwargs)
# Update PYTHONPATH to use local site-packages for inventory scripts.
python_paths = env.get('PYTHONPATH', '').split(os.pathsep)
local_site_packages = self.get_path_to('..', 'lib', 'site-packages')
if local_site_packages not in python_paths:
python_paths.insert(0, local_site_packages)
env['PYTHONPATH'] = os.pathsep.join(python_paths)
# Pass inventory source ID to inventory script.
inventory_source = inventory_update.inventory_source
env['INVENTORY_SOURCE_ID'] = str(inventory_source.pk)