# Windows Playbook Fails Using win\_user

**URL:** <https://forum.ansible.com/t/windows-playbook-fails-using-win-user/22273>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [August 11, 2016, 2:47pm UTC](https://forum.ansible.com/t/windows-playbook-fails-using-win-user/22273 "2016-08-11T14:47:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 11, 2016, 2:47pm UTC](https://forum.ansible.com/t/windows-playbook-fails-using-win-user/22273/1 "2016-08-11T14:47:37Z")

</div>

Trying to run a playbook to add a user on a windows server and getting errors, see below

> [root@localhost group\_vars]# ansible-playbook createuser.yml
> 
> ERROR! Syntax Error while loading YAML.
> 
> The error appears to have been in ‘/etc/ansible/group\_vars/createuser.yml’: line 2, column 1, but may
> 
> be elsewhere in the file depending on the exact syntax problem.
> 
> The offending line appears to be:
> 
> - name: Add a user
> 
> hosts: all
> 
> ^ here

I have a /etc/ansible/group\_vars/windows.yml setup as follows

> ansible\_ssh\_user: Administrator
> 
> ansible\_ssh\_pass: Liverpool27
> 
> ansible\_ssh\_port: 5986
> 
> ansible\_connection: winrm
> 
> ansible\_winrm\_server\_cert\_validation: ignore

I have a /etc/ansible/group\_vars/createuser.yml as follows

> - name: Add a user
> 
> hosts: all
> 
> gather\_facts: false
> 
> tasks:
> 
> - name: Add User
> 
> win\_user:
> 
> name: ansible1
> 
> password: “@ns1bl3”
> 
> state: present
> 
> groups: [“Users”]

Also have a hosts file setup under /etc/ansible/hosts

> [windows]  
> 10.10.128.0

When I run the command manually with the one liner it works fine -  
ansible windows --module-name=win\_user --args=“name=ansible password=fooBar1+3”

If I try and run it with the following it still doesnt work → ansible-playbook -i 10.10.128.0 createuser.yml

Suggestions welcome… Thanks

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [August 11, 2016, 4:49pm UTC](https://forum.ansible.com/t/windows-playbook-fails-using-win-user/22273/2 "2016-08-11T16:49:48Z")

</div>

Unless it’s just Google Groups eating the formatting, it looks like your YAML indentation is hosed up (Ansible’s failing on the control side, not on the Windows module). YAML is whitespace-sensitive, so it should look like:

- name: Add a user  
hosts: all  
gather\_facts: false  
tasks:
- name: Add User  
win\_user:  
name: ansible1  
password: “@ns1bl3”  
state: present  
groups: [“Users”]

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 11, 2016, 5:36pm UTC](https://forum.ansible.com/t/windows-playbook-fails-using-win-user/22273/3 "2016-08-11T17:36:24Z")

</div>

That was perfect. Thanks!
