Lint errors cause molecule to skip cleanup
See original GitHub issueIssue Type
- Bug report
Molecule and Ansible details
ansible --version && molecule --version
ansible 2.7.9
config file = None
configured module search path = [u'/Users/ghibourg/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.15 (default, Sep 18 2018, 20:16:18) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]
molecule, version 2.20.0
Molecule installation method (one of):
- pip
Ansible installation method (one of):
- pip
Detail any linters or test runners used:
-
yaml-lint
-
ansible-lint
-
cleanup playbook defined
Desired Behavior
Given molecule test
with linters and a cleanup step configured, when the lint step errors out,
molecule should call the cleanup step and then the destroy step.
Actual Behaviour
Linting errors directly call destroy
, never calling the cleanup
step.
$ molecule init role -r test && cd test
$ cat molecule/default/molecule.yml
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: instance
image: centos:7
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
cleanup: cleanup.yml
verifier:
name: testinfra
lint:
name: flake8
$ cat molecule/default/cleanup.yml
---
- name: Cleanup
hosts: localhost
tasks:
- name: Debug
debug:
msg: "Cleanup"
$ molecule test
--> Validating schema /Users/ghibourg/Projects/test/molecule/default/molecule.yml.
Validation completed successfully.
--> Test matrix
βββ default
βββ lint
βββ cleanup
βββ destroy
βββ dependency βββ syntax
βββ create
βββ prepare
βββ converge
βββ idempotence βββ side_effect
βββ verify
βββ cleanup
βββ destroy
--> Scenario: 'default'
--> Action: 'lint'
--> Executing Yamllint on files found in /Users/ghibourg/Projects/test/...
Lint completed successfully.
--> Executing Flake8 on files found in /Users/ghibourg/Projects/test/molecule/default/tests/...
Lint completed successfully.
--> Executing Ansible Lint on /Users/ghibourg/Projects/test/molecule/default/playbook.yml...
[701] Role info should contain platforms
/Users/ghibourg/Projects/test/meta/main.yml:2
{'meta/main.yml': {'__file__': u'/Users/ghibourg/Projects/test/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company':
u'your company (optional)', u'galaxy_tags': [], '__line__': 3, '__file__': u'/Users/ghibourg/Projects/test/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 2}}
[703] Should change default metadata: author
/Users/ghibourg/Projects/test/meta/main.yml:2
{'meta/main.yml': {'__file__': u'/Users/ghibourg/Projects/test/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company':
u'your company (optional)', u'galaxy_tags': [], '__line__': 3, '__file__': u'/Users/ghibourg/Projects/test/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 2}}
[703] Should change default metadata: description
/Users/ghibourg/Projects/test/meta/main.yml:2
{'meta/main.yml': {'__file__': u'/Users/ghibourg/Projects/test/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company':
u'your company (optional)', u'galaxy_tags': [], '__line__': 3, '__file__': u'/Users/ghibourg/Projects/test/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 2}}
[703] Should change default metadata: company
/Users/ghibourg/Projects/test/meta/main.yml:2
{'meta/main.yml': {'__file__': u'/Users/ghibourg/Projects/test/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company':
u'your company (optional)', u'galaxy_tags': [], '__line__': 3, '__file__': u'/Users/ghibourg/Projects/test/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 2}}
[703] Should change default metadata: license
/Users/ghibourg/Projects/test/meta/main.yml:2
{'meta/main.yml': {'__file__': u'/Users/ghibourg/Projects/test/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company':
u'your company (optional)', u'galaxy_tags': [], '__line__': 3, '__file__': u'/Users/ghibourg/Projects/test/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 2}}
An error occurred during the test sequence action: 'lint'. Cleaning up.
--> Scenario: 'default'
--> Action: 'destroy'
PLAY [Destroy] *****************************************************************
TASK [Destroy molecule instance(s)] ********************************************
changed: [localhost] => (item=None)
changed: [localhost]
TASK [Wait for instance(s) deletion to complete] *******************************
ok: [localhost] => (item=None)
ok: [localhost]
TASK [Delete docker network(s)] ************************************************
PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Lint errors cause molecule to skip cleanup Β· Issue #1902
Given molecule test with linters and a cleanup step configured, when the lint step errors out, molecule should call the cleanup step and...
Read more >Configuration β Molecule Documentation
The cleanup playbook is for cleaning up test infrastructure that may not be present on the instance that will be destroyed. The primary...
Read more >Ignore certain lint errors ? - Google Groups
to molecule-users. Hi there. I know this is probably bad practice but I would like to know if it's possible to ignore certain...
Read more >Molecule complaining about "[703] Should change default ...
By default, a converge sequence does not contain a lint stage. So you can run your test playbook without having to verify everything....
Read more >Testing your Ansible roles with Molecule - Jeff Geerling
After a couple minutes, Molecule runs through all the testing steps: linting, checking playbook syntax, building the Docker environment,Β ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am currently working on a PR for this issue.
OK, we merged #1903, letβs close this off.