Skip to content

Commit

Permalink
Allow shutil to copy into existing isolation directory (#1311)
Browse files Browse the repository at this point in the history
* allow copy to existing directory since it was created with mkdtemp
* update test for updated copytree call
  • Loading branch information
christophert authored Oct 17, 2023
1 parent 60cfaa1 commit 5d155be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ansible_runner/config/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 5d155be

Please sign in to comment.