ERROR: with_items is not a legal parameter at this level in an Ansible Playbook

Hi, what do I do wrong?

with_items is for tasks, not for plays, not sure what you are trying
to do there with sudoUser.

My fault!

This one works

  • hosts: all
    user: “{{ sudoUser }}”
    sudo: True
    roles:
  • common

I have different default passwordless sudo for AWS instance and Vagrant machine. So I want to pass it’s name from outside.

Problem solved.

you can set the group_var ansible_sudo_user (ansbile_become_user
starting at 1.9) and you won't have to manually add it every time.

Aha, I already did it.
with_items was wrong way to pass it as variable
user: “{{ sudoUser }}”
is right way.