diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 7f993ad7f431..9c7b12b21cbe 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -865,12 +865,14 @@ def build_params_process_isolation(self, instance, private_data_dir, cwd): if getattr(settings, 'AWX_ANSIBLE_COLLECTIONS_PATHS', []): show_paths.extend(settings.AWX_ANSIBLE_COLLECTIONS_PATHS) - pi_path = tempfile.mkdtemp( - prefix='ansible_runner_pi_', - dir=settings.AWX_PROOT_BASE_PATH - ) - os.chmod(pi_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) - self.cleanup_paths.append(pi_path) + pi_path = settings.AWX_PROOT_BASE_PATH + if not self.instance.is_isolated(): + pi_path = tempfile.mkdtemp( + prefix='ansible_runner_pi_', + dir=settings.AWX_PROOT_BASE_PATH + ) + os.chmod(pi_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) + self.cleanup_paths.append(pi_path) process_isolation_params = { 'process_isolation': True, diff --git a/awx/main/tests/unit/test_tasks.py b/awx/main/tests/unit/test_tasks.py index 683f965985fe..75d616ac3bd3 100644 --- a/awx/main/tests/unit/test_tasks.py +++ b/awx/main/tests/unit/test_tasks.py @@ -434,6 +434,7 @@ def test_uses_process_isolation(self, settings): job = Job(project=Project(), inventory=Inventory()) task = tasks.RunJob() task.should_use_proot = lambda instance: True + task.instance = job private_data_dir = '/foo' cwd = '/bar' @@ -1701,6 +1702,7 @@ def project_update(self): def test_process_isolation_exposes_projects_root(self, private_data_dir, project_update): task = tasks.RunProjectUpdate() task.revision_path = 'foobar' + task.instance = project_update ssh = CredentialType.defaults['ssh']() project_update.scm_type = 'git' project_update.credential = Credential(