molecule: yamllint is not found when running 'lint' target as of Molecule 3.0.7

Issue Type

  • Bug report

Molecule and Ansible details

Ansible 2.9.12
Molecule 3.0.7

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Detail any linters or test runners used:

yamllint and ansible-lint, test is run in Travis CI environment

Desired Behavior

Linters should run without issue.

Actual Behaviour

--> Scenario: 'default'
--> Action: 'lint'
--> Executing: set -e
yamllint .
ansible-lint
/bin/sh: 2: yamllint: not found
ERROR: Lint failed: Command 'set -e
yamllint .
ansible-lint
' returned non-zero exit status 127.: Command 'set -e
yamllint .
ansible-lint
' returned non-zero exit status 127.

See failed build: https://travis-ci.org/github/geerlingguy/ansible-role-clamav/jobs/718754330#L470

It looks like this bug was introduced in the 3.0.7 release. If I pip install molecule===3.0.6 the problem goes away.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 8
  • Comments: 16 (10 by maintainers)

Commits related to this issue

Most upvoted comments

OK, here’s what’s going on:

I have yamllint installed through Fedora package manager. So without passing the PATH value through to the environment my system is picking up /usr/bin/yamllint. When I send through the PATH value, I get the yamllint that’s installed in my virtualenv.

Since the previous behavior of molecule was to run with the entire invoking environment, I’m going to submit a patch that passes the entirety of os.environ through along with the MOLECULE_ values unless someone objects to that.

For a quick-and-dirty workaround while waiting for the next release, add the following PATH= line in the lint block, before running the linters:

lint: |
  set -e
  PATH=${PATH}
  yamllint .
  ...

The PATH variable will be expanded by molecule BEFORE running the shell script, instead of being expanded by the shell of the lint block.