Skip to content

Commit

Permalink
Additionally mount ~/.ssh/ to /root/.ssh inside EEs
Browse files Browse the repository at this point in the history
Currently when running inside an EE as root, only SSH_AUTH_SOCK is working. This enables the usage of default key names under ~/.ssh/ on the host.
  • Loading branch information
shanemcd committed Sep 16, 2021
1 parent f741c29 commit 403bfee
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ansible_runner/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ def cli_mounts():
'src': '{}/.ssh/'.format(os.environ['HOME']),
'dest': '/home/runner/.ssh/'
},
{
'src': '{}/.ssh/'.format(os.environ['HOME']),
'dest': '/root/.ssh/'
},
{
'src': '/etc/ssh/ssh_known_hosts',
'dest': '/etc/ssh/ssh_known_hosts'
Expand Down
3 changes: 2 additions & 1 deletion test/unit/config/test__base.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ def test_containerization_settings(tmp_path, container_runtime, mocker):
'--interactive',
'--workdir',
'/runner/project',
'-v', '{}/.ssh/:/home/runner/.ssh/'.format(str(tmp_path))
'-v', '{}/.ssh/:/home/runner/.ssh/'.format(str(tmp_path)),
'-v', '{}/.ssh/:/root/.ssh/'.format(str(tmp_path)),
]

if container_runtime == 'podman':
Expand Down
1 change: 1 addition & 0 deletions test/unit/config/test_ansible_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def test_prepare_config_command_with_containerization(tmp_path, container_runtim
'--workdir',
'/runner/project',
'-v', '{}/.ssh/:/home/runner/.ssh/'.format(rc.private_data_dir),
'-v', '{}/.ssh/:/root/.ssh/'.format(str(tmp_path)),
]

if container_runtime == 'podman':
Expand Down
1 change: 1 addition & 0 deletions test/unit/config/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def test_prepare_run_command_with_containerization(tmp_path, container_runtime,
'/runner/project',
'-v', '{}/:{}/'.format(cwd, cwd),
'-v', '{}/.ssh/:/home/runner/.ssh/'.format(rc.private_data_dir),
'-v', '{}/.ssh/:/root/.ssh/'.format(rc.private_data_dir),
]

if container_runtime == 'podman':
Expand Down
2 changes: 2 additions & 0 deletions test/unit/config/test_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def test_prepare_plugin_docs_command_with_containerization(tmp_path, container_r
'--workdir',
'/runner/project',
'-v', '{}/.ssh/:/home/runner/.ssh/'.format(rc.private_data_dir),
'-v', '{}/.ssh/:/root/.ssh/'.format(rc.private_data_dir),
]

if container_runtime == 'podman':
Expand Down Expand Up @@ -161,6 +162,7 @@ def test_prepare_plugin_list_command_with_containerization(tmp_path, container_r
'--workdir',
'/runner/project',
'-v', '{}/.ssh/:/home/runner/.ssh/'.format(rc.private_data_dir),
'-v', '{}/.ssh/:/root/.ssh/'.format(rc.private_data_dir),
]

if container_runtime == 'podman':
Expand Down
1 change: 1 addition & 0 deletions test/unit/config/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def test_prepare_inventory_command_with_containerization(tmp_path, container_run
'--workdir',
'/runner/project',
'-v', '{}/.ssh/:/home/runner/.ssh/'.format(rc.private_data_dir),
'-v', '{}/.ssh/:/root/.ssh/'.format(rc.private_data_dir),
]

if container_runtime == 'podman':
Expand Down

0 comments on commit 403bfee

Please sign in to comment.