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

206 views
Skip to first unread message

Serega Sheypak

unread,
Apr 24, 2015, 8:01:22 AM4/24/15
to ansible...@googlegroups.com
Hi, what do I do wrong?

---
- hosts: all
  user: "{{ item }}"
  sudo: True
  with_items:
      - "{{ sudoUser }}"
  roles:
    - common

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

Brian Coca

unread,
Apr 24, 2015, 9:53:07 AM4/24/15
to ansible...@googlegroups.com
with_items is for tasks, not for plays, not sure what you are trying
to do there with sudoUser.



--
Brian Coca

Serega Sheypak

unread,
Apr 24, 2015, 11:00:52 AM4/24/15
to ansible...@googlegroups.com
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.


пятница, 24 апреля 2015 г., 15:53:07 UTC+2 пользователь Brian Coca написал:

Serega Sheypak

unread,
Apr 24, 2015, 11:01:14 AM4/24/15
to ansible...@googlegroups.com
Problem solved.

Brian Coca

unread,
Apr 24, 2015, 11:06:49 AM4/24/15
to ansible...@googlegroups.com
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.

On Fri, Apr 24, 2015 at 11:01 AM, Serega Sheypak
<serega....@gmail.com> wrote:
> Problem solved.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b6b5d8d9-c7e8-4a39-9fec-5d93660866ca%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Serega Sheypak

unread,
Apr 24, 2015, 11:14:32 AM4/24/15
to ansible...@googlegroups.com
Aha, I already did it.
with_items was wrong way to pass it as variable
user: "{{ sudoUser }}"
is right way.

пятница, 24 апреля 2015 г., 17:06:49 UTC+2 пользователь Brian Coca написал:
Reply all
Reply to author
Forward
0 new messages