Interview › Infrastructure as Code (Terraform, Ansible)
What is ansible-lint, and what does it catch?
Infrastructure as Code (Terraform, Ansible) · Advanced level
Answer
ansible-lint is a static analysis tool for Ansible content. It catches risky patterns, style issues, deprecated syntax, missing names, non-idempotent commands, YAML issues, and best-practice violations before playbooks reach production.
Technical explanation
ansible-lint codifies team standards and Ansible best practices.
Rule violations should either be fixed or explicitly justified with narrow skips.
Run it locally and in CI so feedback is early.
Prefer idempotent modules over shell so repeated runs are safe and change reporting is meaningful.
Separate reusable role logic from inventory-specific variables so the same automation works across environments.
Run lint, syntax checks, check mode where useful, and staged rollouts before production-wide changes.
Hands-on example
1. Add Ansible safety checks for: What is ansible-lint, and what does it catch?
2. CI commands:
ansible-playbook --syntax-check site.yml
ansible-lint.
yamllint.
ansible-playbook -i inventory/stage site.yml --check --diff3. Avoid state: latest in production unless the rollout is explicitly an upgrade window. Prefer pinned versions or approved repositories:
- name: Install approved app version
ansible.builtin.package:
name: myapp-1.8.4
state: present4. For mixed fleets, drive differences through group_vars, host_vars, and facts rather than copied playbooks.
5. Gate production runs behind review and record playbook version, inventory, operator, and output artifact.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Infrastructure as Code (Terraform, Ansible) interview questions
- How do you integrate Ansible into CI/CD and keep playbooks tested?
- When would you choose Ansible over Terraform and vice versa?
- How would you orchestrate a rolling, health-checked upgrade across servers with Ansible?
- Can Terraform and Ansible be used together, and how would you combine them?
- How do you handle host-specific differences across a mixed fleet?
- What is Kustomize, and how does it differ from Helm?
- What is the difference between state: present and state: latest, and the risk of latest?
- What is a kustomization.yaml, and what does it define?