Ansible-lint

From Freephile Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

When developing Meza (or other Ansible project) on your local workstation without a virtual environment (e.g. VirtualBox) or VM, or Docker container - IOW, hacking old-school with just a git checkout - you will still want to have ansible-lint. To do this, create a Python Virtual Environment for your project and activate it. And then install ansible-lint in the Virtual Environment. Meza is pre-configured to ignore .venv or any directory ending in 'venv'

On an Ubuntu workstation, that's as easy as:

cd ~/src/meza
python -m venv .venv
source ./.venv/bin/activate
pip install ansible-lint
ansible-lint --help

Using it in VSCode

  • You will probably need to activate your venv in the VSCode terminal.
  • You can always exit the venv simply with 'deactivate'.
  • VSCode will kill the venv when you exit the application - which means you need to reactivate if you restart VSCode.

Bonus

With a Python Virtual Environment enabled, you can install any other tools you need like pylint, yamllint, autopep8 etc.