On 02. juni 2017 03:33, Anfield wrote:
> ---
> - hosts: localhost
> become: yes
> tasks:
> - name: Check if a file exists
> stat:
> path: /home/ansible/test.txt
> register: file
> - debug: var="file exists"
> when: file.stat.exists == true
>
> The above doesnt work, can anyone tell me why?
The var= in debug is for variables, for text you need to use msg=
So to print out the content of your file.
- debug: var=file
To print text:
- debug: msg="file exist and content of exists {{ file.stat.exists }}"
Since file is a module name, you shouldn't use that as you variable name.
--
Kai Stian Olstad