Skip to content

Commit

Permalink
fix defaults for container opts with roles
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrews committed Nov 18, 2024
1 parent 3a9946f commit 728b9ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ansible_runner/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from ansible_runner import output
from ansible_runner import cleanup
from ansible_runner._internal._dump_artifacts import dump_artifact
from ansible_runner.defaults import default_process_isolation_executable
from ansible_runner.utils import Bunch, register_for_cleanup
from ansible_runner.utils.capacity import get_cpu_count, get_mem_in_bytes, ensure_uuid
from ansible_runner.utils.importlib_compat import importlib_metadata
Expand Down Expand Up @@ -884,8 +885,8 @@ def main(sys_args=None):
"project_dir": vargs.get('project_dir'),
"artifact_dir": vargs.get('artifact_dir'),
"roles_path": [vargs.get('roles_path')] if vargs.get('roles_path') else None,
"process_isolation": vargs.get('process_isolation'),
"process_isolation_executable": vargs.get('process_isolation_executable'),
"process_isolation": bool(vargs.get('process_isolation')),
"process_isolation_executable": vargs.get('process_isolation_executable') or default_process_isolation_executable,
"process_isolation_path": vargs.get('process_isolation_path'),
"process_isolation_hide_paths": vargs.get('process_isolation_hide_paths'),
"process_isolation_show_paths": vargs.get('process_isolation_show_paths'),
Expand Down
19 changes: 19 additions & 0 deletions test/integration/test_transmit_worker_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,25 @@ def worker_stream(transmit_stream, tmp_path): # pylint: disable=W0621
return ingoing_buffer


def test_transmit_role(tmp_path, cli, project_fixtures):
"""When transmitting a role job via CLI, expect only 'playbook' in the job arguments.
When we 'transmit' a role through the CLI command, we expect a playbook to be generated via
the role_manager(), which will in turn be transmitted as an artifact. No other parameters
are expected to be present.
"""
outgoing_buffer = tmp_path / 'buffer'
outgoing_buffer.touch()

transmit_dir = project_fixtures / 'debug'

r = cli(['transmit', str(transmit_dir), '--role', 'hello_world'])
data = json.loads(r.stdout.split('\n')[0])
assert 'kwargs' in data
assert len(data['kwargs']) == 1
assert 'playbook' in data['kwargs']


def test_worker_without_delete_no_dir(tmp_path, cli, transmit_stream): # pylint: disable=W0621
worker_dir = tmp_path / 'for_worker'

Expand Down

0 comments on commit 728b9ff

Please sign in to comment.