Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set no_log: true for molecule internal playbook tasks?

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

like image 627
ckaserer Avatar asked Nov 18 '19 15:11

ckaserer


1 Answers

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

  • https://github.com/ansible/molecule
like image 133
ckaserer Avatar answered Oct 02 '22 22:10

ckaserer