vscode-ansible
vscode-ansible copied to clipboard
Only generic errors reported by ansible-lint
Summary
When I write Ansible files, everythong mostly works, but sometimes, I get a linter complaint. Often, I already know what is wrong and fix it, but sometimes I'm baffled by why the line is red, and hover over it or go to the problems view. There, I see:
[{
"resource": "/home/me/ansible/roles/whatever/tasks/main.yml",
"owner": "_generated_diagnostic_collection_name_#2",
"severity": 8,
"message": "Rule violations reported by YamlLint when this is installed.\n\nYou can fully disable all of them by adding 'yaml' to the 'skip_list'.\n\nSpecific tag identifiers that are printed at the end of rule name,\nlike 'trailing-spaces' or 'indentation' can also be be skipped, allowing\nyou to have a more fine control.\n\nBy default this rule is not used when yamllint library is missing. If you want\nto make its absence a runtime failure, please add 'yaml' to 'enable_list'\ninside the configuration file.\n",
"source": "ansible-lint",
"startLineNumber": 12,
"startColumn": 1,
"endLineNumber": 12,
"endColumn": 2147483648
}
This does not tell me what is wrong with the line, and as far as I can tell, it's the same text for any rule violation. The actual violated rule should be reported back, I would think, instead of this generic help text that only explains what errors are in general.
Extension version
v2.4.78
VS Code version
1.79.2
Ansible Version
09:38 $ ansible --version
ansible [core 2.12.0]
config file = None
configured module search path = ['/home/me/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/me/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]
jinja version = 3.0.3
libyaml = True
OS / Environment
Windows 10, WSL2 with Ubuntu 20.04, yamllint 1.26.3, ansible-lint 5.4.0 using ansible 2.12.0
Relevant log output
There is no `Output/Ansible Server` option, only `Ansible Support`, which does not log anything when I save an Ansible yaml file.
Addon: I filed this as a bug instead of a feature request as I assume this is not working as intended, and is supposed to return the actual error. Should the above behaviour be 'as designed', let me know and I'll refile as a feature request.
@Gaibhne, Ansible Support is the option that shows the output. You have 2 options under it: message
, which gives generic messages, and verbose
, which gives more detailed outputs.
Furthermore, I would like to know the source of the error, which you should be able to find it in the Problems
tab. If this is coming from ansible-lint, you need to upgrade the ansible-lint version as you are using a very old version of ansible-lint, i.e., v5.4.0.
The only options I see are Clear output
and Turn autoscrolling off
. No options named message
or verbose
are visible. Yes, the error is coming from ansible-lint, which I will see if I can update somehow. I am using the version that comes with Ubuntu LTS 20, which I would not have exepcted to be very old.
I have updated to ansible-lint 6.17.2
and now no longer get any linting at all, nor any errors, nor any output at all in Ansible Support
. Calling ansible-lint
from the console correctly lints my files.
Talking about the setting: here it is: ansibleServer.trace.server
, and you have the following options for it: off
, message
, and verbose
. You can try it out.
About no linting, make sure to have the ansible.validation.enabled
set to true
and ansible.validation.lint
set to true
as well.
Same for me, no linting at all, while working fine on CLI. Here are some probably relevant traces:
[Trace - 13:16:36] Sending response 'workspace/configuration - (3)'. Processing request took 1ms
Result: [
{
"ansible": {
"path": "ansible",
"useFullyQualifiedCollectionNames": true,
"reuseTerminal": false
},
"python": {
"interpreterPath": "/usr/bin/python3",
"activationScript": ""
},
"ansibleNavigator": {
"path": "ansible-navigator"
},
"completion": {
"provideRedirectModules": true,
"provideModuleOptionAliases": true
},
"validation": {
"enabled": true,
"lint": {
"enabled": true,
"path": "ansible-lint",
"arguments": ""
}
},
"executionEnvironment": {
"enabled": false,
"containerEngine": "auto",
"containerOptions": "",
"image": "ghcr.io/ansible/creator-ee:latest",
"pull": {
"arguments": "",
"policy": "missing"
},
"volumeMounts": []
},
"lightspeed": {
"enabled": false,
"URL": "https://c.ai.ansible.redhat.com",
"suggestions": {
"enabled": false
},
"modelIdOverride": ""
}
}
]
...
Path for lint: /home/myuser/.local/bin/ansible-lint
Validating using ansible-lint
[Trace - 13:16:36] Received request 'window/workDoneProgress/create - (4)'.
Params: {
"token": "4d477867-4da5-4f27-9944-68c67390af20"
}
[Trace - 13:16:36] Sending response 'window/workDoneProgress/create - (4)'. Processing request took 0ms
No result returned.
[Trace - 13:16:36] Received notification '$/progress'.
Params: {
"token": "4d477867-4da5-4f27-9944-68c67390af20",
"value": {
"kind": "begin",
"title": "ansible-lint",
"message": "Processing files..."
}
}
...
[Trace - 13:16:37] Received notification 'update/ansible-metadata'.
Params: [
[
{
"ansible information": {
"core version": "2.16.4",
"location": "/home/myuser/.local/share/pipx/venvs/ansible/lib/python3.10/site-packages/ansible",
"config file path": "/home/myuser/Developer/gitlab.corp.net/ansible/playbooks/ansible-playbook-base/ansible.cfg",
"collections location": [
"/home/myuser/.ansible/collections",
"/usr/share/ansible/collections",
"",
"/usr/lib/python310.zip",
"/usr/lib/python3.10",
"/usr/lib/python3.10/lib-dynload",
"/home/myuser/.local/lib/python3.10/site-packages",
"/usr/local/lib/python3.10/dist-packages",
"/usr/lib/python3/dist-packages"
],
"modules location": [
"/home/myuser/.ansible/plugins/modules",
"/usr/share/ansible/plugins/modules",
"/home/myuser/.local/share/pipx/venvs/ansible/lib/python3.10/site-packages/ansible/modules"
],
"default host list path": [
"/etc/ansible/hosts"
]
},
"python information": {
"version": "3.10.12",
"location": "/usr/bin/python3"
},
"ansible-lint information": {
"version": "24.2.0",
"location": "/home/myuser/.local/bin/ansible-lint",
"config file path": "/home/myuser/Developer/gitlab.corp.net/ansible/playbooks/ansible-playbook-base/.ansible-lint"
}
}
]
]