vscode-ansible
vscode-ansible copied to clipboard
Report if ansible-lint is broken
As ansible-lint have very special requirements for running, we need to be sure that we run ansible-lint --version
and report any potential error in a visible way in the UI.
This should make it easier for users to debug broken or incomplete installs of ansible-lint tool.
Related: https://github.com/ansible-community/ansible-lint/issues/1507
I was going to work on this, but there's already a little error popup. If not installed:
Command failed: ansible-lint --offline --nocolor -f codeclimate "/tmp/vsc/playbook.yml"
/bin/sh: 1: ansible-lint: not found
If pointing to the ansible-lint in a venv without pointing the rest of the extension to the venv:
Command failed: ./.venv/bin/python /tmp/vsc/.venv/bin/ansible-lint --offline --nocolor -f codeclimate "/tmp/vsc/playbook.yml"
Failed to guess project directory using git:
ERROR No module named 'ansible'
FATAL: ansible-lint requires a version of Ansible package >= 2.9, but none was found. Please install a compatible version using the same python interpreter. See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-with-pip
I think this issue already done?
@ssbarnea, @lilatomic This PR: https://github.com/ansible/ansible-language-server/pull/5 takes care of the following issue. If there is some problem in installation or configuration of ansible-lint, it reports the user and falls back to --syntax-check.
ansible-lint does not work with this extension but works with a previous extension below.
https://marketplace.visualstudio.com/items?itemName=tomaciazek.ansible
The previous one shows red error with ansible-lint as below.
However, this extension does not with the same setting.
I set ansible.path, ansibleLint.path, and python.interpreterPath, but does not work. Other features such as autocompletion are working.
My environment is below.
-
OS WSL (venv)
-
ansible --version ansible [core 2.11.2] config file = /home/ubuntu/venv/heart-ansible/ansible.cfg configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/ubuntu/venv/lib/python3.8/site-packages/ansible ansible collection location = /home/ubuntu/.ansible/collections:/usr/share/ansible/collections executable location = /home/ubuntu/venv/bin/ansible python version = 3.8.5 (default, May 27 2021, 13:30:53) [GCC 9.3.0] jinja version = 3.0.1 libyaml = True
-
ansible-lint --version ansible-lint 5.0.12 using ansible 2.11.2
I hope to use ansible-lint with new extension as previous one is deprecated.
The Ansible extension 0.7.1 still doesn't have ansible-lint integration working, as @yoshiotobe demonstrated above.
ansible-lint 5.3.2 using ansible 2.12.1
Update: works with extension 0.8.1 and ansible-lint 5.4.0 using ansible 2.12.3