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