Este conteúdo não está disponível no idioma selecionado.

Chapter 4. Manually adding the Ansible language to YAML files


The Ansible VS Code extension works only when the language associated with a file is set to Ansible. The extension provides features that help create Ansible playbooks, such as auto-completion, hover, and diagnostics.

The Ansible VS Code extension automatically associates the Ansible language with some files. The procedures below describe how to set the language for files that are not recognized as Ansible files.

4.1. Associating the Ansible language to YAML files

The following procedure describes how to manually assign the Ansible language to a YAML file that is open in VS Code.

Procedure

  1. Open or create a YAML file in VS Code.
  2. Hover the cursor over the language identified in the status bar at the bottom of the VS Code window to open the Select Language Mode list.
  3. Select Ansible in the list.

    The language shown in the status bar at the bottom of the VS Code window for the file is changed to Ansible.

4.2. Adding persistent file association for the Ansible language to settings.json

Instead of manually associating the Ansible language to YAML files, you can add file association for the Ansible language in your settings.json file.

Procedure

  1. Open the settings.json file:

    1. Click View Command Palette to open the command palette.
    2. Enter Workspace settings in the search box and select Open Workspace Settings (JSON).
  2. Add the following code to settings.json.

    {
      ...
    
      "files.associations": {
        "*plays.yml": "ansible",
        "*init.yml": "yaml",
      }
    }
    Copy to Clipboard Toggle word wrap
Voltar ao topo
Red Hat logoGithubredditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

Theme

© 2025 Red Hat