Linters in the Techlab
In our ongoing series about building a robust CI/CD pipeline, we’re focusing on the foundation: the development environment. Our “techlab,” as shown in the pipeline diagram, is where the magic happens. To ensure we’re building quality code from the start, we’re integrating linters into our workflow.

What are Linters?
Think of linters as automated code inspectors. They analyze your code for potential errors, style inconsistencies, and deviations from best practices. This helps us catch problems early on and maintain a high standard of code quality throughout the project.
Linters in Our Tech Lab
Our techlab is equipped with the following linters:
- ansible-lint: This linter focuses on Ansible playbooks and roles, ensuring we’re following best practices and avoiding common pitfalls. This is crucial for maintaining efficient and reliable infrastructure automation.
- yamllint: YAML files are essential for configuration management.
yamllinthelps us keep these files clean, consistent, and error-free. - pylint: For our Python scripts,
pylintenforces PEP 8 coding standards and identifies potential errors. This leads to more readable and maintainable code. - shellcheck: Shell scripts are often used for automation tasks.
shellcheckhelps us write more robust and reliable scripts by identifying potential issues and bad practices. - tflint: We’re using Terraform to manage our infrastructure as code.
tflintensures our Terraform configurations are correct, efficient, and adhere to best practices.
Installing Linters and VS Code Extensions
Here’s how to set up these linters, along with corresponding VS Code extensions for real-time feedback:
1. ansible-lint
- Installation:
pip install ansible-lint - VS Code Extension: Ansible by Red Hat (search for “Ansible” in the extensions marketplace)
2. yamllint
- Installation:
pip install yamllint - VS Code Extension: YAML by Red Hat (search for “YAML” in the extensions marketplace)
3. pylint
- Installation:
pip install pylint - VS Code Extension: Python by Microsoft (search for “Python” in the extensions marketplace)
4. shellcheck
- Installation:
- Linux:
sudo apt install shellcheck
- Linux:
- VS Code Extension: ShellCheck (search for “ShellCheck” in the extensions marketplace)
5. tflint
We are going to use the install script to get the default settings for tflint; however customizations are available. Refer to the GitHub page for details.
- Installation:
- Linux:
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
- Linux:
- VS Code Extension: Terraform by HashiCorp (search for “Terraform” in the extensions marketplace)
By incorporating these linters into our techlab development machine, we’re establishing a solid foundation for our CI/CD pipeline. But linters are only the first step! Next time, we’ll introduce code formatters that will automatically keep our code readable and consistent with best practices.