# Ansible 2.3 create new group on a host fails.

**URL:** <https://forum.ansible.com/t/ansible-2-3-create-new-group-on-a-host-fails/24995>\
**Category:** Ansible Project\
**Created:** [July 15, 2017, 4:18pm UTC](https://forum.ansible.com/t/ansible-2-3-create-new-group-on-a-host-fails/24995 "2017-07-15T16:18:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NixGeek](https://avatars.discourse-cdn.com/v4/letter/n/ac8455/32.png) [@NixGeek](https://forum.ansible.com/u/NixGeek)\
**Post date:** [July 15, 2017, 4:18pm UTC](https://forum.ansible.com/t/ansible-2-3-create-new-group-on-a-host-fails/24995/1 "2017-07-15T16:18:01Z")

</div>

My Ansible version:

ansible-playbook 2.3.1.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = Default w/o overrides  
python version = 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609]

Per the documentation to add a group

```auto
# Example group command from Ansible Playbooks
- group:
    name: somegroup
    state: present

```

```auto
My playbook
======================================
---

- hosts: myhosts
  tasks:

- group:
    name: useradmins
    state: present
=======================================

```

```auto

```

when I run I get errors:

# ansible-playbook -v addgroup.yml

Using /etc/ansible/ansible.cfg as config file

ERROR! ‘group’ is not a valid attribute for a Play

The error appears to have been in ‘/etc/ansible/playbooks/addgroup.yml’: line 6, column 3, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- group:  
^ here

---

<div class="post-metadata">

**Author:** ![Andreas\_Olsson](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Andreas\_Olsson](https://forum.ansible.com/u/Andreas_Olsson)\
**Post date:** [July 15, 2017, 4:34pm UTC](https://forum.ansible.com/t/ansible-2-3-create-new-group-on-a-host-fails/24995/2 "2017-07-15T16:34:20Z")

</div>

lör 2017-07-15 klockan 09:18 -0700 skrev NixGeek:

> # My playbook
> 
> ---
> 
> - hosts: myhosts  
> tasks:
> 
> # - group: name: useradmins state: present

It looks as if you have gotten the indentation wrong. You want the  
group creation to be a list item under tasks.

- hosts: myhosts  
tasks:  
- group:  
name: useradmins  
state: present

// Andreas

---

<div class="post-metadata">

**Author:** ![NixGeek](https://avatars.discourse-cdn.com/v4/letter/n/ac8455/32.png) [@NixGeek](https://forum.ansible.com/u/NixGeek)\
**Post date:** [July 15, 2017, 6:04pm UTC](https://forum.ansible.com/t/ansible-2-3-create-new-group-on-a-host-fails/24995/3 "2017-07-15T18:04:03Z")

</div>

man one reason ansible makes me crazy is the silly indented crap in the playbook.

Thank you for helping me.

---

<div class="post-metadata">

**Author:** ![Andreas\_Olsson](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Andreas\_Olsson](https://forum.ansible.com/u/Andreas_Olsson)\
**Post date:** [July 15, 2017, 6:39pm UTC](https://forum.ansible.com/t/ansible-2-3-create-new-group-on-a-host-fails/24995/4 "2017-07-15T18:39:57Z")

</div>

lör 2017-07-15 klockan 11:04 -0700 skrev NixGeek:

> man one reason ansible makes me crazy is the silly indented crap in  
> the playbook.

That "silly indented crap" is more formally referred to as YAML. For  
better or worse it's fairly commonly used. Investing a bit of time in  
understanding YAML will easily pay off in the long run.

Using a text editor with YAML support is also helpful.

// Andreas
