DEV Community

MasaWorkout
MasaWorkout

Posted on • Originally published at Medium

I tried Ansible-lint quickly

I know Ansible-lint recently. I tried it right away and I think want to write a blog.Ansible-lint is a sentence structure check tool. By use it, we get beautiful playbook.
I write to introduce Ansible-lint right away.

pip install ansible-lint
pip list
>ansible-lint                           4.1.0

This is sample playbook.

- name: example
  action: ec2_metadata_facts
  when: production == True
- debug: var=ansible_ec2_instance_id

I got this result after I apply Ansible-lint to this playbook.

[601] Don't compare to literal True/False
roles/common/tasks/main.yml:3
  when: production == True
601 is error number. By reading this link, I can understand the error.
https://docs.ansible.com/ansible-lint/rules/default_rules.html
Use when: var rather than when: var == True (or conversely when: not var)

So, I fixed this playbook after I applied Ansible-lint. This playbook doesn't have an error and it was beautiful playbook.
I think adopt Ansible-lint in CI.

Top comments (0)