Ansible Linter configuration

Ansible is a popular IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.

Enable Ansible analysis

Ansible Linter is not enabled by default to not analyze random YAML files in your repository. If you want to leverage this Infrastructure as Code analysis, add the .codeac.yml configuration file below to your repository root. Also, specify path to your Ansible roles and playbooks to eliminate errors from other YAML files.

.codeac.yml

version: '1'

tools:
  ansibleLint:
    files:
      - playbooks/**/*.yml
      - roles/

Ignoring files

Ansible Linter requires configuration via a .ansible-lint configuration file as detailed in Ansible Linter's documentation .

.ansible-lint

exclude_paths:
  - ./my/excluded/directory/
  - ./my/other/excluded/directory/
  - ./last/excluded/directory/

Declarative Ansible Example

Ansible’s philosophy is that it should be declarative. Changing things only when they are needed improves your reliability as well as execution performance. Also, proper task names add documentation to your playbook.

Ansible - Commands should not change thing if nothing needs doing