Bhautik_K
(Bhautik K)
December 7, 2017, 2:56pm
1
Looking for solution. I have write below yml for if directory is exists or not but getting below error. Could you please correct me where I did mistake ?
tasks:
name: Ansible check directory exists.
stat:
path=/etc/yum.repos.d
register: p
msg:“Path exists and is a directory”
when: p.stat.isdir is defined and p.stat.isdir
change:
`
msg:“Path exists and is a directory”
`
to:
`
msg: “Path exists and is a directory”
`
Missing space…
Bhautik_K
(Bhautik K)
December 7, 2017, 6:30pm
3
Hi Smith,
Tried making space but still same error.
Regards,
Bhautik
You have wrong indentation, the debug task as one space to much.
It need to be indented at the same level as the stat task.
As @kai mentioned. Your indentation is off. Here is a workable playbook for you https://gist.github.com/mrlesmithjr/039a7bccf342e456dc6f9cbb2474c995
Bhautik_K
(Bhautik K)
December 7, 2017, 7:01pm
6
Thanks Kai Stian Olstad,it’s work but how we can identify small syntax error ? Which editor is good to use for ansible ?
Regards,
Bhautik