Hi Friends ,
When I tried to run any .yml task on the Ansible , I get following error ;
My Syntax is here ,
- name: Create directory structure
win_file:
path: C:\Temp\folder\subfolder
state: directory
ERROR! ‘win_file’ is not a valid attribute for a Play
The error appears to have been in ‘/etc/ansible/create.yml’: line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
name: Create directory structure
^ here
Any ideal ?
You don’t have whitespace right, which Ansible is very finicky about.
Try:
name: Create directory structure
win_file:
path: C:\Temp\folder\subfolder
state: directory
Don’t use “tab” keys, use your space bar.
HTH,
Larry
Tchia04
(Tchia04)
March 14, 2018, 4:45pm
4
do you have “tasks:” defined before your win_file?
try this
hosts: all
tasks:
name: Create directory structure
win_file:
path: C:\Temp\folder\subfolder
state: directory
jborean
(Jordan Borean)
March 14, 2018, 8:38pm
5
Yep, the post above is your problem, you are trying to run a list of tasks under ansible-playbook when you need to structure it like a play. When referring to roles you can just have the tasks but the root playbook must include things like hosts, tasks, roles and so on as the root keys.
Thanks
Jordan