Standard Ansible Loop Script not working

12 views
Skip to first unread message

Carlton Patterson

unread,
May 14, 2018, 6:06:23 PM5/14/18
to Ansible Project
Hello community,

I have written the following ansible script

---
# Playbook file: loopplay.yml
-
    name
: loopplay
    hosts
: centos2
    tags
:
       
- loopplay
    tasks
:
       
-
            name
: looptask
            user
:
                name
: "{{ item }}"
                state
: present
                groups
: "wheel"
            loop
:
               
- testuser1
               
- testuser2
               


However, I keep on getting the following error:gg

The error appears to have been in '/opt/ansible-projects/test_5af9a55448f0c8003531a07d_loopproject/loopplay.yml': line 10, column 13, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
-
name: looptask
^ here


Can someone let me know where I'm going wrong?


Thanks

Brian Coca

unread,
May 14, 2018, 6:12:07 PM5/14/18
to Ansible Project
don't offset from list item:

# Playbook file: loopplay.yml
- name: loopplay
hosts: centos2
tags:
- loopplay
tasks:
- name: looptask
user:
name: "{{ item }}"
state: present
groups: "wheel"
loop:
- testuser1
- testuser2


--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages