From d6985bee47c57258fa5e31cd0b26b15223aedd2c Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 29 Jun 2021 12:49:11 +0200 Subject: [PATCH] Add support for ansible args in the test subcommand (#3166) --- src/molecule/command/test.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/molecule/command/test.py b/src/molecule/command/test.py index 18109e3d43..804992de66 100644 --- a/src/molecule/command/test.py +++ b/src/molecule/command/test.py @@ -55,6 +55,13 @@ class Test(base.Base): Target all scenarios. + .. option:: molecule test -- -vvv --tags foo,bar + + Providing additional command line arguments to the `ansible-playbook` + command. Use this option with care, as there is no sanitation or + validation of input. Options passed on the CLI are combined with options + provided in provisioner's `options` section of `molecule.yml`. + .. program:: molecule test --destroy=always .. option:: molecule test --destroy=always @@ -129,7 +136,10 @@ def execute(self): default=MOLECULE_PARALLEL, help="Enable or disable parallel mode. Default is disabled.", ) -def test(ctx, scenario_name, driver_name, __all, destroy, parallel): # pragma: no cover +@click.argument("ansible_args", nargs=-1, type=click.UNPROCESSED) +def test( + ctx, scenario_name, driver_name, __all, destroy, parallel, ansible_args +): # pragma: no cover """Test (dependency, lint, cleanup, destroy, syntax, create, prepare, converge, idempotence, side_effect, verify, cleanup, destroy).""" args = ctx.obj.get("args") subcommand = base._get_subcommand(__name__) @@ -146,4 +156,4 @@ def test(ctx, scenario_name, driver_name, __all, destroy, parallel): # pragma: if parallel: util.validate_parallel_cmd_args(command_args) - base.execute_cmdline_scenarios(scenario_name, args, command_args) + base.execute_cmdline_scenarios(scenario_name, args, command_args, ansible_args)