Search code examples
visual-studio-codeansibleyamlredhat

vs-code editor for yaml says expecting a map but found a sequence


i'm editing a main.yml in an ansible role's tasks folder.

i'm using the YAML vscode extension by Red Hat.

Here's the first part of the file...

# Install Packages
- name: Install the Kafka Broker Packages
  yum:
    name: "{{item}}-{{confluent.package_version}}"
    state: latest
  loop: "{{kafka_broker_packages}}"
  when: ansible_os_family == "RedHat"

- name: Install the Kafka Broker Packages
  apt:
    name: "{{item}}={{confluent.package_version}}"
    update_cache: yes
  loop: "{{kafka_broker_packages}}"
  when: ansible_os_family == "Debian"

the entire file has the red squiggly underline saying:

Expecting a 'map', but found a 'sequence'

i'm sure i'm doing something silly - any help is greatly appreciated


Solution

  • The cause of this issue is that the ansible extension (https://marketplace.visualstudio.com/items?itemName=vscoss.vscode-ansible) doesn't recognize the given file as its supported item. To get rid of it, try editing the settings.json of VSCode to add the following configuration:

    "files.associations": {
        "**/*.yml": "ansible"
    },
    "ansible.validation": true