6

I am testing version compatibility with molecule and for the combination

python 3.8 x ansible latest x debian

molecule breaks in the instance creation step with

TASK [Wait for instance(s) creation to complete] *******************************
FAILED - RETRYING: Wait for instance(s) creation to complete (300 retries left).
failed: [localhost] (item=None) => {"attempts": 2, "censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}
fatal: [localhost]: FAILED! => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}

PLAY RECAP *********************************************************************
localhost                  : ok=6    changed=3    unreachable=0    failed=1    skipped=3    rescued=0    ignored=0

https://travis-ci.com/ckaserer/ansible-role-example/jobs/256557752

In order to debug further, I need to set the no_log: false.

Any ideas on how to set no_log to true for molecule's own internal playbooks?

I tried with MOLECULE_DEBUG, but that did not do the trick.
Searching molecule's doc did not give any results either. running molecule with

molecule --debug test

also does not set the molecule playbook variable for no_log to false

ckaserer
  • 4,827
  • 3
  • 18
  • 33
  • If you downvote, then please take the time and inform me which additional information would be beneficial such that I can update the question. – ckaserer Nov 18 '19 at 15:35
  • 1
    Being precise: you don't want to set `no_log: true` but `no_log: false`. In your current context, this is normally done by using the `--debug` option to molecule (see [example for ansible provisionner and docker driver `create.yml` playbook](https://github.com/ansible/molecule/blob/496201dcd476097f2225b2646e19ea9a6b0302da/molecule/provisioner/ansible/playbooks/docker/create.yml#L6)). I use this every day almost without problems. I suggest you retry and investigate why it does not work as expected on your installation. – Zeitounator Nov 18 '19 at 16:04
  • Yes, --debug works for your own playbooks, but it seems it does not work for the playbooks defined in molecule. Here is a build with `molecule --debug test` that still does not show me the details that I need. https://travis-ci.com/ckaserer/ansible-role-example/jobs/257811789 – ckaserer Nov 18 '19 at 16:10
  • I just prooved you above it is supposed to work with the included playbooks and told you I was using this almost everyday while developping with molecule. – Zeitounator Nov 18 '19 at 16:12
  • Please take a look at the referenced build. As you can see the debug option in molecule sets various environment variables, but it does not set `MOLECULE_NO_LOG`. at least not in molecule, version 2.22 – ckaserer Nov 18 '19 at 16:17
  • I believe you use molecule almost every day, but there is a difference between `debug` and `no_log`. `no_log` should only be used to mask sensitive data and is not affected by the `debug` flag in molecule. – ckaserer Nov 18 '19 at 16:26
  • in your `molecule.yml` file, under `provisioner:` add `log: true` will give you more output. – crsuarezf Jan 31 '20 at 20:00

1 Answers1

11

You can set the environment variable

MOLECULE_NO_LOG="false"

and then run your normal molecule command .e.g.

molecule test

That wasn't easy to find, I had to take a look at the source code of molecule and found that

molecule/test/resources/playbooks/docker/create.yml

which is the playbook used to create docker images that are defined by Dockerfile.j2 uses the variable molecule_no_log to set the no_log value in the playbook.

Additionally, in

molecule/test/unit/provisioner/test_ansible.py

the variable molecule_no_log is based on the environment variable MOLECULE_NO_LOG

So, in the end, I just needed to set the appropriate environment variable to false.

Molecule source code

ckaserer
  • 4,827
  • 3
  • 18
  • 33