DEV Community

MasaWorkout
MasaWorkout

Posted on • Originally published at Medium

1 1

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.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More