question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lint errors cause molecule to skip cleanup

See original GitHub issue

Issue 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:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ghislainbourgeoiscommented, Apr 3, 2019

I am currently working on a PR for this issue.

0reactions
decentral1secommented, Apr 4, 2019

OK, we merged #1903, let’s close this off.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found