Skip to content

Latest commit

 

History

History
141 lines (88 loc) · 4.54 KB

README.md

File metadata and controls

141 lines (88 loc) · 4.54 KB

IntelliJ Ansible Lint IntelliJ Ansible Lint

A plugin for the IntelliJ platform utilizing Ansible Lint.

Table of Contents

Screenshots

Annotations on all tasks with issues:

editor1

Concrete details on mouseover:

editor2

Different visualization based on severity:

editor3

Quick actions:

editor4

editor5

Security relevant information:

editor6

Requirements

Your system needs to have Ansible Lint version 6.14.3 (or later) installed.
(Previous versions should work; but may not provide optimal/expected results.)

NOTE

The plugin does not detect or use any (virtual) environment settings of your current project to run ansible-lint.
Alternative installation methods (like Poetry, Homebrew, etc.) are also not supported.

ansible-lint needs to be runnable directly from your computer's command line.

If your package manager doesn't provide ansible-lint or you want to install a more up-to-date version, then a suggested setup would be as follows:

  • create an ansible-lint folder in your home directory:

    mkdir ~/ansible-lint
    
  • change into it, and create a dedicated virtual environment:

    cd ~/ansible-lint
    python3 -m venv venv
    
  • activate the virtual environment and install ansible-lint via pip:

    source venv/bin/activate
    pip install ansible-lint
    
  • finally, create this script file (~/ansible-lint/run.sh):

    #!/bin/bash
    source ~/ansible-lint/venv/bin/activate
    ansible-lint "${@}"
    
  • don't forget to make it executable:

    chmod +x ~/ansible-lint/run.sh
    

Reference this script in the plugin; and you should be ready to go. 👍

(Using pipx to install specific versions of ansible and ansible-lint is also a valid alternative; reportedly working fine.)

🌟 NEW 🌟 | Windows Subsystem for Linux (WSL)

The plugin now officially supports WSL.
However, I still consider the implementation as "experimental".

I tested everything myself using a standard WSL-installation on Windows11 with Ubuntu as distro.

Simply install ansible and ansible-lint using the apt package manager; then set ansible-lint as command in the settings-dialog and activate the "Use WSL" checkbox.

Feel free to give feedback if it works for you as well.

Installation

Use the IDE's built-in plugin system:

  • File --> Settings... --> Plugins --> Marketplace
  • search for: Ansible Lint
  • click the Install-button

Or go to the plugin page on the JetBrains-website, download the archive-file and install manually.

Setup

After installing the plugin you should go to the settings dialog and hit the Test button to check if ansible-lint is fully operable.

settings

Adjust the command path and/or options as needed.

⚠️ NOTE

By default, the plugin will only start linting YAML-files if your project root contains one of these configuration files:

  • .ansible-lint
  • .config/ansible-lint.yml

You can eiter create one manually or use the statusbar pop-up actions; which will be available when a YAML file is opened (and no config file is present):

statusbar

It is possible to use the plugin without a config file (see settings dialog above). However, this would mean that every YAML-file will unnecessarily be passed to ansible-lint; even in Non-Ansible projects.

License

Please read the license file.

Credits

Donate

If you like this plugin, please consider a donation. Thank you!