Skip to content

Language Server

The Ansible language server provides YAML completion, hover documentation, and diagnostics for Ansible playbooks, roles, and task files. It implements the Language Server Protocol and works with any LSP-compatible editor.

Feature Description
Completion Module names, parameter names, parameter values (choices), Jinja2 filters
Hover Module documentation, parameter descriptions, and defaults on hover
Diagnostics YAML syntax errors, unknown modules, missing required parameters
Semantic tokens Syntax highlighting for Ansible-specific constructs

Every pull request produces a standalone language-server.js file as a CI artifact. Download it from the Actions tab.

If you install the Ansible DevTools Plugin, the language server is bundled at servers/language-server.js inside the plugin directory.

Terminal window
git clone https://github.com/ansible/vscode-ansible.git
cd vscode-ansible
git checkout next
pnpm install --frozen-lockfile
pnpm run build
# Output: dist/language-server.js (single file, ~1.3MB)
Terminal window
node language-server.js --stdio

The server communicates over stdio using JSON-RPC (standard LSP transport). It requires:

  • Node.js >= 20
  • Python 3 with ansible-core installed (for module discovery and documentation)
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
configs.ansible_ls = {
default_config = {
cmd = { 'node', '/path/to/language-server.js', '--stdio' },
filetypes = { 'yaml', 'yaml.ansible' },
root_dir = lspconfig.util.root_pattern(
'ansible.cfg', '.ansible-lint', 'galaxy.yml', 'playbooks/'
),
settings = {
ansible = {
validation = { enabled = true },
completion = { enabled = true },
},
},
},
}
lspconfig.ansible_ls.setup({})

The VS Code extension bundles and manages the language server automatically — no manual configuration needed. The standalone server is for editors that don’t support VS Code extensions but do support LSP.

Both use the same codebase (packages/language-server/) and produce identical behavior.