Can't specify Ansible verbosity as a molecule option
Apologies if this is working as intended. I've tried to search for it but didn't see anywhere that this was a deprecation change.
Specifying the vvv: true option on the provider section of a molecule.yml has no effect even when molecule is ran with or without the --debug flag.
The documentation, under the section which explains how to override playbook files, shows the following snippet:
provisioner:
name: ansible
options:
vvv: True
playbooks:
create: create.yml
converge: converge.yml
destroy: destroy.yml
Using vvv: True has no effect. Using vvv: true also has no effect. This used to work on previous molecule versions (3.0.x if I recall correctly).
I'm aware that there are alternatives, such as:
- Pass the desired verbosity to the
moleculecommand (molecule -vvv converge ...). - Pass the desired verbosity as an Ansible argument to molecule (
molecule converge -- -vvv). - Specify the desired verbosity on an environment variable (
ANSIBLE_VERBOSITY: '3').
I'm opening this issue just to clarify wether this is an intentional change or not. In case it is I guess that that documentation should be fixed.
Issue Type
- Bug report
Molecule and Ansible details
ansible [core 2.11.1]
config file = None
configured module search path = ['/home/hector/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/hector/.local/lib/python3.8/site-packages/ansible
ansible collection location = /home/hector/.ansible/collections:/usr/share/ansible/collections
executable location = /home/hector/.local/bin/ansible
python version = 3.8.5 (default, May 27 2021, 13:30:53) [GCC 9.3.0]
jinja version = 2.11.2
libyaml = True
molecule 3.3.4 using python 3.8
ansible:2.11.1
delegated:3.3.4 from molecule
docker:0.3.3 from molecule_docker
vagrant:0.6.1 from molecule_vagrant
Molecule installation method (one of):
- pip
Ansible installation method (one of):
- pip
Detail any linters or test runners used:
- yamllint
- ansible-lint
- gitlab-runner and on local development aswell
Desired Behavior
Either the documentation should not provide examples with the vv option and say that option does not work or specifying the options v, vv or vvv, ... in the molecule file should pass the desired verbosity to the ansible-playbook command.
Actual Behaviour
ansible-playbook is ran without verbosity (the -vvv parameter).
There's a minimum complete verifiable example in this repo.
This is the output of a molecule --debug converge with the vvv: true option set (note that no -vvv flag is passed to ansible-playbook):
COMMAND: ansible-playbook --diff --inventory /home/hector/.cache/molecule/molecule_bug_vvv/default/inventory --skip-tags molecule-notest,notest /home/hector/repos/github/molecule/molecule_bug_vvv/molecule/default/converge.yml
PLAY [Converge] ****************************************************************
TASK [Gathering Facts] *********************************************************
ok: [python]
TASK [Include molecule_bug_vvv] ************************************************
TASK [molecule_bug_vvv : This is a command that shows some output] *************
changed: [python]
PLAY RECAP *********************************************************************
python : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
I do not remember removing such a feature myself and I am inclined to believe that we should just remove it from the docs. Having an yaml option vvv does not make any sense to me, what about 1, 2, 3, or 5 v's? ;)
Just in case my original issue wasn't clear: the docs mention vvv but v, vv, ... all worked as expected.
IMHO removing it seems fine but it should be acknowledged that it won't work in the docs to prevent people from trying to figure out why it doesn't.
I think this feature is very useful. Not sure why it has been removed, but I don't think it should be. When you use the ANSIBLE_VERBOSITY environment variable, you actually end up getting all molecule phases outputting at that verbosity level rather than just the provisioner phases.
Have you tried using one of the following options and see if it fits for your use case?
- Pass the desired verbosity to the molecule command (
molecule -vvv converge ...). - Pass the desired verbosity as an Ansible argument to molecule (
molecule converge -- -vvv).
Hi @hluaces, I'm using molecule test instead of molecule converge. The first option you proposed has the same effect as using ANSIBLE_VERBOSITY=3 while the second doesn't work with molecule test.
I'm not able to get molecule to pass ANY amount of -v to ansible-playbook using any techniques mentioned:
- passing
-vvvor--debugtomolecule - using
provisioner:
name: ansible
options:
vvv: True
- exporting
ANSIBLE_VERBOSITY=3env var.
Some of these make molecule more verbose, but the call to the converge.yml playbook is still the vanilla:
ansible-playbook --inventory /home/tim/.cache/molecule/ansible/deb10-headless/inventory --skip-tags molecule-notest,notest /home/tim/src/timblaktu-cm/ansible/molecule/deb10-headless/converge.yml
Trying to troubleshoot an ansible issue within molecule and not getting enough info..
Also faced the same problem, passing env to provisioner seems to work fine:
...
provisioner:
name: ansible
env:
ANSIBLE_VERBOSITY: 3
...