Repository navigation
fix: pass provisioner verbosity options to ansible - #4709
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. ℹ️ Recent review info
Walkthrough
Merge Risk:
|
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly identifies the main change: passing provisioner verbosity options to Ansible. |
| Linked Issues check | ✅ Passed | Issue #3159 requires v, vv, and vvv provisioner options to reach Ansible. AnsiblePlaybook._build_command now adds the computed verbose_flag to both ansible-playbook and ansible-navigator… |
| Out of Scope Changes check | ✅ Passed | The command changes and tests address issue #3159. Removing util.bool2args supports the fix because the changed call sites no longer use that no-op helper. Test annotations and documentation strings… |
| Docstring Coverage | ✅ Passed | Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. |
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
Comment @coderabbitai help to get the list of available commands.
7bf0769 to
39642c5
Compare
`provisioner.options.vvv` (and `vv`/`v`) is documented to raise Ansible verbosity but is silently dropped: the command builder routed the extracted verbose flag through `util.bool2args()`, a no-op stub that always returns an empty list, so `-vvv` never reached the ansible-playbook or ansible-navigator command line. The same drop affects `molecule --debug`, which sets `vvv` internally, so `--debug` also ran Ansible at verbosity 0. Spread `verbose_flag` directly in both backend branches of `_build_command()`, matching how the ansible-galaxy dependency and testinfra verifier already emit it, and remove the unused `bool2args` helper (its only two callers were these lines). Add bake-level tests asserting the verbosity flag reaches the built command, parametrized over `v`/`vv`/`vvv` for both backends and covering the `--debug` path. Fixes ansible#3159 Assisted-by: Claude (Anthropic) Signed-off-by: Jeff Pullen <9343691+jeffcpullen@users.noreply.github.com>
f89221e to
186c142
Compare
|
Hi @jeffcpullen, LGTM. Root cause analysis is accurate: Please get CI green first (the current |
|
Thanks @Hrithik-Gavankar. The |
@Hrithik-Gavankar we are back to green now that #4710 is merged |
fix: pass provisioner verbosity options to ansible
Fixes #3159.
Problem
The Ansible provisioner's verbosity option is documented as a way to raise Ansible verbosity, but it is silently dropped. The flag never reaches the
ansible-playbook(oransible-navigator) command line, so the run stays at verbosity 0. The same drop affectsmolecule --debug, which raises verbosity the same way internally, so--debugran Ansible at verbosity 0 as well.The scenario below sets the documented option and runs converge on it. On a clean checkout the run shows none of the markers Ansible prints only at verbosity 1 and above, such as the interpreter banner and the per-task path lines.
Molecule converge - missing expected 'task path:' debug output
Molecule converge with --debug - missing expected 'task path:' debug output
No verbosity banner, no
task path:. Neither-vvvnor--debugwas applied.Root cause
In
src/molecule/provisioner/ansible_playbook.py,bake()computes the flag correctly (verbose_flag = util.verbose_flag(options)yields["-vvv"]and strips thev*keys fromoptions). But_build_command()then emits it throughutil.bool2args(verbose_flag), andutil.bool2argsis a stub that unconditionally returns[]regardless of its argument. The finished["-vvv"]is computed and thrown away.bool2argswas born a no-op in the 2020 refactor that moved command building off theshlibrary (#2917). The same change handled the two sibling call sites (the ansible-galaxy dep 8000 endency step and the testinfra verifier) correctly, spreading*verbose_flaginline, which is why onlyprovisioner.optionsverbosity is affected. A later navigator-executor rewrite (#4457) copied the broken line into the ansible-navigator branch, so both backends now drop it.bool2argshas no other callers. The option worked from 2017 until #2917 and is still the documented way to set per-scenario verbosity, so this restores it rather than removing the docs.The gap stayed quiet for ~5 years because the tests assert the computed value (
verbose_flag()returns["-vvv"]) and the config object (optionscontainsvvv: True), but never the built command. The galaxy path already has a bake-level test asserting-vreaches the command. The provisioner lacked the equivalent.Changes
*verbose_flagdirectly in both backend branches of_build_command()(ansible-playbook and ansible-navigator), matching the galaxy dependency and testinfra verifier paths that already work.util.bool2args, whose only two callers were these lines.v/vv/vvvfor both backends and covering the--debugpath.With the fix, the same scenario raises verbosity: the
ansible-playbook [core ...]banner andtask path:lines now appear.molecule --debugraises verbosity through the same internal path, and was dropped the same way. Run against the same setup, minus anyprovisioner.options, so the--debugflag is the only variable. Before the fix it still runs at verbosity 0. With the fix, the banner and per-task path appear.Environment for all runs: ansible-core 2.21.4, Python 3.13. Before is a clean
upstream/main. After is that same base plus this commit.The transcripts above exercise the
ansible-playbookbackend. Theansible-navigatorbackend carries the identical fix and is covered by the parametrized bake test that asserts the flag reaches its command line.Risk / Impact
None known
Test plan
tox -e lintgreentox -e pkggreentox -e pyfull suite green, same skips asmain(918 passed / 7 skipped, vs 911 / 7 onmain)main, green on the branch, one per backend (7 fail onmain:v/vv/vvvfor each backend plus the--debugtest)main(90% on both)provisioner.options.vvvexample now behaves as documentedRelated
molecule -v/-vv/-vvv converge, andprovisioner.env: {ANSIBLE_VERBOSITY: 3}.Summary by CodeRabbit
v,vv, orvvvproduces the corresponding verbosity level, and enabling debug mode applies maximum verbosity. Command output now reflects the selected level in both execution modes.