diff --git a/src/ansible_runner/config/runner.py b/src/ansible_runner/config/runner.py index 70379ef3..adf24e8e 100644 --- a/src/ansible_runner/config/runner.py +++ b/src/ansible_runner/config/runner.py @@ -135,7 +135,7 @@ def prepare(self): self.directory_isolation_path = tempfile.mkdtemp(prefix='runner_di_', dir=self.directory_isolation_path) if os.path.exists(self.project_dir): output.debug(f"Copying directory tree from {self.project_dir} to {self.directory_isolation_path} for working directory isolation") - shutil.copytree(self.project_dir, self.directory_isolation_path, symlinks=True) + shutil.copytree(self.project_dir, self.directory_isolation_path, dirs_exist_ok=True, symlinks=True) self.prepare_inventory() self.prepare_command() diff --git a/test/unit/config/test_runner.py b/test/unit/config/test_runner.py index 397fd9a5..b8848ac1 100644 --- a/test/unit/config/test_runner.py +++ b/test/unit/config/test_runner.py @@ -239,7 +239,7 @@ def test_prepare_env_directory_isolation_from_settings(mocker, project_fixtures) mkdtemp.assert_called_once_with(prefix='runner_di_', dir='/tmp/runner') # The project files should be copied to the isolation path. - copy_tree.assert_called_once_with(rc.project_dir, rc.directory_isolation_path, symlinks=True) + copy_tree.assert_called_once_with(rc.project_dir, rc.directory_isolation_path, dirs_exist_ok=True, symlinks=True) def test_prepare_inventory(mocker):