From afcfe2f51b9a13d9bbee14007cb9de69ff1b9eab Mon Sep 17 00:00:00 2001 From: abikouo Date: Fri, 25 Jun 2021 15:32:09 +0200 Subject: [PATCH 1/3] add support for ansible args for molecule test command --- src/molecule/command/test.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/molecule/command/test.py b/src/molecule/command/test.py index 18109e3d4..f4a7fcba5 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 override options + provided in provisioner's `options` section of `molecule.yml`. + .. program:: molecule test --destroy=always .. option:: molecule test --destroy=always @@ -129,7 +136,8 @@ 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 +154,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) From fe93ca4b05c8f848b87a96e80180b9454d5bb301 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Fri, 25 Jun 2021 16:31:35 +0200 Subject: [PATCH 2/3] Update test.py --- src/molecule/command/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/molecule/command/test.py b/src/molecule/command/test.py index f4a7fcba5..c9d88fde5 100644 --- a/src/molecule/command/test.py +++ b/src/molecule/command/test.py @@ -59,7 +59,7 @@ class Test(base.Base): 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 override options + 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 From c4f0f17dabcb67c0f1977a93e97c3f4b1e8492d6 Mon Sep 17 00:00:00 2001 From: abikouo Date: Tue, 29 Jun 2021 12:28:48 +0200 Subject: [PATCH 3/3] black my file --- src/molecule/command/test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/molecule/command/test.py b/src/molecule/command/test.py index c9d88fde5..804992de6 100644 --- a/src/molecule/command/test.py +++ b/src/molecule/command/test.py @@ -137,7 +137,9 @@ def execute(self): help="Enable or disable parallel mode. Default is disabled.", ) @click.argument("ansible_args", nargs=-1, type=click.UNPROCESSED) -def test(ctx, scenario_name, driver_name, __all, destroy, parallel, ansible_args): # pragma: no cover +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__)