diff options
-rw-r--r-- | awx/main/management/commands/inventory_import.py | 18 | ||||
-rw-r--r-- | awx/main/tasks.py | 22 | ||||
-rw-r--r-- | awx/main/utils/common.py | 5 | ||||
-rw-r--r-- | awx/settings/development.py | 2 | ||||
-rw-r--r-- | awx/settings/production.py | 2 | ||||
-rw-r--r-- | tox.ini | 2 |
6 files changed, 19 insertions, 32 deletions
diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index b088877e8e..63760eb6a9 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -80,17 +80,15 @@ class AnsibleInventoryLoader(object): self.is_vendored_source = True def build_env(self): - # Use ansible venv if it's available and setup to use env = dict(os.environ.items()) - if settings.ANSIBLE_USE_VENV: - env['VIRTUAL_ENV'] = settings.ANSIBLE_VENV_PATH - env['PATH'] = os.path.join(settings.ANSIBLE_VENV_PATH, "bin") + ":" + env['PATH'] - venv_libdir = os.path.join(settings.ANSIBLE_VENV_PATH, "lib") - env.pop('PYTHONPATH', None) # default to none if no python_ver matches - for python_ver in ["python2.7", "python2.6"]: - if os.path.isdir(os.path.join(venv_libdir, python_ver)): - env['PYTHONPATH'] = os.path.join(venv_libdir, python_ver, "site-packages") + ":" - break + env['VIRTUAL_ENV'] = settings.ANSIBLE_VENV_PATH + env['PATH'] = os.path.join(settings.ANSIBLE_VENV_PATH, "bin") + ":" + env['PATH'] + venv_libdir = os.path.join(settings.ANSIBLE_VENV_PATH, "lib") + env.pop('PYTHONPATH', None) # default to none if no python_ver matches + for python_ver in ["python2.7", "python2.6"]: + if os.path.isdir(os.path.join(venv_libdir, python_ver)): + env['PYTHONPATH'] = os.path.join(venv_libdir, python_ver, "site-packages") + ":" + break return env def get_base_args(self): diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 8445e6ce19..12be78e4d5 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -467,24 +467,22 @@ class BaseTask(Task): } def add_ansible_venv(self, env, add_tower_lib=True): - if settings.ANSIBLE_USE_VENV: - env['VIRTUAL_ENV'] = settings.ANSIBLE_VENV_PATH - env['PATH'] = os.path.join(settings.ANSIBLE_VENV_PATH, "bin") + ":" + env['PATH'] - venv_libdir = os.path.join(settings.ANSIBLE_VENV_PATH, "lib") - env.pop('PYTHONPATH', None) # default to none if no python_ver matches - for python_ver in ["python2.7", "python2.6"]: - if os.path.isdir(os.path.join(venv_libdir, python_ver)): - env['PYTHONPATH'] = os.path.join(venv_libdir, python_ver, "site-packages") + ":" - break + env['VIRTUAL_ENV'] = settings.ANSIBLE_VENV_PATH + env['PATH'] = os.path.join(settings.ANSIBLE_VENV_PATH, "bin") + ":" + env['PATH'] + venv_libdir = os.path.join(settings.ANSIBLE_VENV_PATH, "lib") + env.pop('PYTHONPATH', None) # default to none if no python_ver matches + for python_ver in ["python2.7", "python2.6"]: + if os.path.isdir(os.path.join(venv_libdir, python_ver)): + env['PYTHONPATH'] = os.path.join(venv_libdir, python_ver, "site-packages") + ":" + break # Add awx/lib to PYTHONPATH. if add_tower_lib: env['PYTHONPATH'] = env.get('PYTHONPATH', '') + self.get_path_to('..', 'lib') + ':' return env def add_tower_venv(self, env): - if settings.TOWER_USE_VENV: - env['VIRTUAL_ENV'] = settings.TOWER_VENV_PATH - env['PATH'] = os.path.join(settings.TOWER_VENV_PATH, "bin") + ":" + env['PATH'] + env['VIRTUAL_ENV'] = settings.TOWER_VENV_PATH + env['PATH'] = os.path.join(settings.TOWER_VENV_PATH, "bin") + ":" + env['PATH'] return env def build_env(self, instance, **kwargs): diff --git a/awx/main/utils/common.py b/awx/main/utils/common.py index b345a93de3..d67f91706d 100644 --- a/awx/main/utils/common.py +++ b/awx/main/utils/common.py @@ -641,10 +641,7 @@ def wrap_args_with_proot(args, cwd, **kwargs): show_paths = [cwd, kwargs['private_data_dir']] else: show_paths = [cwd] - if settings.ANSIBLE_USE_VENV: - show_paths.append(settings.ANSIBLE_VENV_PATH) - if settings.TOWER_USE_VENV: - show_paths.append(settings.TOWER_VENV_PATH) + show_paths.extend([settings.ANSIBLE_VENV_PATH, settings.TOWER_VENV_PATH]) show_paths.extend(getattr(settings, 'AWX_PROOT_SHOW_PATHS', None) or []) for path in sorted(set(show_paths)): if not os.path.exists(path): diff --git a/awx/settings/development.py b/awx/settings/development.py index 414bcfb48f..1dfc679b7e 100644 --- a/awx/settings/development.py +++ b/awx/settings/development.py @@ -98,9 +98,7 @@ for setting in dir(this_module): include(optional('/etc/tower/settings.py'), scope=locals()) include(optional('/etc/tower/conf.d/*.py'), scope=locals()) -ANSIBLE_USE_VENV = True ANSIBLE_VENV_PATH = "/venv/ansible" -TOWER_USE_VENV = True TOWER_VENV_PATH = "/venv/tower" # If any local_*.py files are present in awx/settings/, use them to override diff --git a/awx/settings/production.py b/awx/settings/production.py index ad668784d2..e0625b4508 100644 --- a/awx/settings/production.py +++ b/awx/settings/production.py @@ -43,11 +43,9 @@ JOBOUTPUT_ROOT = '/var/lib/awx/job_status/' SCHEDULE_METADATA_LOCATION = '/var/lib/awx/.tower_cycle' # Ansible base virtualenv paths and enablement -ANSIBLE_USE_VENV = True ANSIBLE_VENV_PATH = "/var/lib/awx/venv/ansible" # Tower base virtualenv paths and enablement -TOWER_USE_VENV = True TOWER_VENV_PATH = "/var/lib/awx/venv/tower" AWX_ISOLATED_USERNAME = 'awx' @@ -16,9 +16,7 @@ setenv = SWIG_FEATURES = -cpperraswarn -includeall -I/usr/include/openssl HOME = {homedir} USERPROFILE = {homedir} - ANSIBLE_USE_VENV = True ANSIBLE_VENV_PATH = {toxworkdir} - TOWER_USE_VENV = True TOWER_VENV_PATH = {toxworkdir} SKIP_SLOW_TESTS = True |