You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code中Ansible扩展无法解析ansible-lint输出问题求助

VS Code Ansible扩展无法解析ansible-lint输出问题

使用VS Code官方Ansible扩展对Playbook执行ansible-lint检查时,打开Playbook能看到ansible-lint启动运行,但会弹出提示:

Could not parse ansible-lint output. Please check your ansible-lint installation & configuration

编辑器内也未按预期用红/黄色下划线标记检查到的错误或警告。查看Ansible Support输出发现,扩展尝试将ansible-lint的文本输出解析为JSON时失败,报错信息为:

Unexpected token 'y', "yaml[empty"... is not valid JSON

但在命令行(CLI)中直接运行ansible-lint完全正常。

已尝试的解决操作

  • 用Python3.14通过pip安装最新版ansible-lint和ansible-core
  • 设置环境变量ANSIBLE_LINT_FORMAT=json指定输出格式
  • 在扩展设置中指定ansible-lint二进制文件的完整路径
  • 重装VS Code的Ansible扩展
  • 重装ansible-core和ansible-lint

环境版本信息

  • 操作系统:Fedora Linux 43 with GNOME 49
  • VS Code:1.122.1(通过RPM文件安装)
  • Ansible扩展:26.5.0
  • Ansible相关:ansible-lint 25,依赖ansible-core:2.18.12、ansible-compat:25.8.1、ruamel-yaml:0.18.16、ruamel-yaml-clib:0.2.12
  • Python:3.14.5

配置文件内容

ansible.cfg文件

[defaults]
# (pathlist) Comma separated list of Ansible inventory sources
inventory=./inventory
remote_user=root

# (path) The vault password file to use. Equivalent to --vault-password-file or --vault-id
# If executable, it will be run and the resulting stdout will be used as the password.
vault_password_file=./.vault_password

# (pathspec) Colon separated paths in which Ansible will search for Roles.
roles_path=./roles:/usr/share/ansible/roles:/etc/ansible/roles

.ansible-lint文件

---
exclude_paths:
  - '.git/'
  - 'files/'
  - 'vars/*pwd*'
  - 'meta/'

kinds:
  - tasks: 'tasks/*.{yml,yaml}'
  - vars: 'vars/*.{yml,yaml}'
  - vars: 'defaults/*.{yml,yaml}'
  - meta: 'meta/main.{yml,yaml}'
  - yaml: '.ansible-lint'
  - yaml: '.pre-commit-config.yaml'
  - yaml: '.yamllint'

loop_var_prefix: '^(__|{role}_)'
max_block_depth: 20
offline: true
profile: 'production'
skip_action_validation: false
skip_list: []
task_name_prefix: '{stem} | '
use_default_rules: true
var_naming_pattern: '^[a-z_][a-z0-9_]*$'
warn_list:
  - 'experimental'
  - 'package-latest'
  - 'no-handler'
write_list:
  - 'none'

内容的提问来源于stack exchange,提问作者Lux

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.02 07:23:11