skip to Main Content

I am new to using molecule and want to enable molecule for my ansible content. This content is a folder containing three playbooks and a folder roles with 8 roles which are used in the playbooks. The playbooks run without problems.

Now I wanted to use molecule with them and my fist step was trying to add linting.

I tested linting with running the command

ansible-lint * --nocolor &>ansible-lint.out

I also created a molecule scenario and added in the file molecule/default/molecule.yml the configuration for lint

---
dependency:
  name: galaxy
driver:
  name: podman
platforms:
  - name: instance
    image: quay.io/centos/centos:stream8
    pre_build_image: true
provisioner:
  name: ansible
verifier:
  name: ansible
lint: |
  set -e
  yamllint .
  ansible-lint .

Wen I run molecule lint the same file will be analysed as when I run ansible-lint *. However it seems that different rules are used.
With ansible-lint the maximum allowed line length is 160 while with molecule lint it is 80. Further on with ansible-lint I see violations which are not reported bye molecule lint. I have not configured the rules to use and are use the standard configuration.
In both situation ansible-lint --version reports.

$ ansible-lint --version
ansible-lint 6.5.0 using ansible 2.13.3

Can someone explain to me why molecule lint is not using the same standard configuration as ansible-lint. Is there some documentation which explains this.

And how can I configure molecule to use the default rules from ansible-lint.

And is molecule lint executed inside the container or outside? I would assume outside.

Frank

2

Answers


  1. Chosen as BEST ANSWER

    Yes the my problem was, that I was not aware that the first problem reported by yamllint will raise an exit code different of 0 and thus prevent the ansible-lint from running. Thus I did never see the output from ansible-lint.

    A second problem is that ansible-lint seem to invoke yamllint but with different default rules.


  2. The linting command inside molecule is deprecated and was already removed from main branch.

    Just run ansible-lint standalone and you will not have such problems.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search