VSChina / vscode-ansible

VSCode extension for ansible
Other
77 stars 48 forks source link

package module should be allowed to have name parameter of type list #260

Open tjanez opened 4 years ago

tjanez commented 4 years ago

Environment

Summary

If one uses a code snippet like:

- name: install the latest version of Apache and MariaDB
  package:
    name:
      - httpd
      - mariadb-server
    state: latest

he would get an error:

Incorrect type. Expected "string".

While the package module documentation doesn't explicitly mention this, it is clear from the Examples section that one could also use a list for the name parameter.

yerzhant commented 4 years ago

I have the same issue. When one have a task in a role with the content:

- name: Install required packages
  yum:
    name:
      - yum-utils
      - device-mapper-persistent-data
      - lvm2
    state: present

Validation error is: Incorrect type. Expected "string". Though a playbook, using the role, does play without any issues.

pgassmann commented 4 years ago

The same problem is with the yum and apt modules.

In the specific package modules it is mentioned: https://docs.ansible.com/ansible/2.9/modules/yum_module.html#parameter-name

To operate on several packages this can accept a comma separated string of packages or (as of 2.0) a list of packages.

https://docs.ansible.com/ansible/2.9/modules/apt_module.html#parameter-name

A list of package names [...]

In Notes for both yum and apt

When used with a loop: each package will be processed individually, it is much more efficient to pass the list directly to the name option.