extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Ansible

Open walterrowe opened this issue 3 years ago • 7 comments

Check for existing issues

  • [X] Completed

Language

ansible / YAML

Tree Sitter parser link

https://github.com/ikatyang/tree-sitter-yaml

Language server link

https://github.com/redhat-developer/yaml-language-server

Misc notes

Would like to see ansible / YAML supported.

walterrowe avatar Dec 16 '22 18:12 walterrowe

Lack of ansible support is the only reason that is holding me back from using Zedd as my full time code editor

aravindh-murugesan avatar Oct 08 '23 05:10 aravindh-murugesan

Ansible is usually done with Jinja templates, so this probably belongs here:

  • Tree Sitter for Jinja2: https://github.com/dbt-labs/tree-sitter-jinja2
  • An up-to-date VIM Grammars for Jinja2: https://github.com/Glench/Vim-Jinja2-Syntax

rosingrind avatar Oct 25 '23 17:10 rosingrind

+1. We do not use Ansible but mostly YAML + Jinja and Zed is a little unusable for that right now.

antoinetielbeke avatar Jan 31 '24 12:01 antoinetielbeke

+1

Would be nice to be capable of to provide which LSP must be used. Taking just a few examples from https://www.schemastore.org/api/json/catalog.json, for instance YAML files.

There are many ways that we should be capable of to do so:

  • By providing the magic comment yaml-language-server an entire set of options could be used.
# yaml-language-server: $schema=https://json.schemastore.org/yamllint.json
---
extends: default
yaml-files: ["*.yaml", "*.yml", ".yamllint"]
ignore: |
  .build/
  .github/
  vendor/

It would be great if there were a setting, such as the fileMatch option, that could automatically configure the url for the LSP. This feature is currently missing in a few examples below.

  • For Docker Compose:
     {
      "name": "docker-compose.yml",
      "description": "The Compose specification establishes a standard for the definition of multi-container platform-agnostic applications",
      "fileMatch": [
        "**/docker-compose.yml",
        "**/docker-compose.yaml",
        "**/docker-compose.*.yml",
        "**/docker-compose.*.yaml",
        "**/compose.yml",
        "**/compose.yaml",
        "**/compose.*.yml",
        "**/compose.*.yaml"
      ],
      "url": "https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"
    }
  • This applies to language subsets as well, such as Ansible, which is the subject of this issue.
[
{
      "name": "Ansible Execution Environment",
      "description": "Ansible execution-environment.yml file",
      "fileMatch": ["**/execution-environment.yml"],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/execution-environment.json"
    },
    {
      "name": "Ansible Meta",
      "description": "Ansible meta/main.yml file",
      "fileMatch": ["**/meta/main.yml"],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/meta.json"
    },
    {
      "name": "Ansible Meta Runtime",
      "description": "Ansible meta/runtime.yml file",
      "fileMatch": ["**/meta/runtime.yml"],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/meta-runtime.json"
    },
    {
      "name": "Ansible Argument Specs",
      "description": "Ansible meta/argument_specs.yml file",
      "fileMatch": ["**/meta/argument_specs.yml"],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/role-arg-spec.json"
    },
    {
      "name": "Ansible Requirements",
      "description": "Ansible requirements file",
      "fileMatch": ["requirements.yml"],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/requirements.json"
    },
    {
      "name": "Ansible Vars File",
      "description": "Ansible variables File",
      "fileMatch": [
        "**/vars/*.yml",
        "**/vars/*.yaml",
        "**/defaults/*.yml",
        "**/defaults/*.yaml",
        "**/host_vars/*.yml",
        "**/host_vars/*.yaml",
        "**/group_vars/*.yml",
        "**/group_vars/*.yaml"
      ],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/vars.json"
    },
    {
      "name": "Ansible Tasks File",
      "description": "Ansible tasks file",
      "fileMatch": [
        "**/tasks/*.yml",
        "**/tasks/*.yaml",
        "**/handlers/*.yml",
        "**/handlers/*.yaml"
      ],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible.json#/$defs/tasks"
    },
    {
      "name": "Ansible Playbook",
      "description": "Ansible playbook files",
      "fileMatch": [
        "playbook.yml",
        "playbook.yaml",
        "site.yml",
        "site.yaml",
        "**/playbooks/*.yml",
        "**/playbooks/*.yaml"
      ],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible.json#/$defs/playbook"
    },
    {
      "name": "Ansible Rulebook",
      "description": "Ansible rulebook files",
      "fileMatch": ["**/rulebooks/*.yml", "**/rulebooks/*.yaml"],
      "url": "https://raw.githubusercontent.com/ansible/ansible-rulebook/main/ansible_rulebook/schema/ruleset_schema.json"
    },
    {
      "name": "Ansible Inventory",
      "description": "Ansible inventory files",
      "fileMatch": ["inventory.yml", "inventory.yaml"],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/inventory.json"
    },
    {
      "name": "Ansible Collection Galaxy",
      "description": "Ansible Collection Galaxy metadata",
      "fileMatch": ["galaxy.yml"],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/galaxy.json"
    },
    {
      "name": "Ansible-lint Configuration",
      "description": "Ansible-lint Configuration",
      "fileMatch": [".ansible-lint", "**/.config/ansible-lint.yml"],
      "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible-lint-config.json"
    },
    {
      "name": "Ansible Navigator Configuration",
      "description": "Ansible Navigator Configuration",
      "fileMatch": [
        ".ansible-navigator.json",
        ".ansible-navigator.yaml",
        ".ansible-navigator.yml",
        "ansible-navigator.json",
        "ansible-navigator.yaml",
        "ansible-navigator.yml"
      ],
      "url": "https://raw.githubusercontent.com/ansible/ansible-navigator/main/src/ansible_navigator/data/ansible-navigator.json"
    }
]

Finally, you can change the language manually through the user interface by selecting the language from the bottom bar or accessing the command palette and toggling the language from there.

VSCode does all that, please double check modelines and file association with ansible-language-server for the Ansible LSP docs

iafelix avatar Feb 21 '24 22:02 iafelix

Any updates?

sathishkumar294 avatar Jul 16 '24 20:07 sathishkumar294

When we can see this implemented on new version of Zed ?

vualett avatar Aug 02 '24 15:08 vualett

https://github.com/ArcherHume/jinja2-support

ehamiter avatar Sep 01 '24 23:09 ehamiter

There is an Ansible extension available now: https://github.com/kartikvashistha/zed-ansible

maxdeviant avatar Oct 30 '24 15:10 maxdeviant