On 07/25/2014 12:44 AM, Michael DeHaan wrote:
> I think I replied to the previous copy of this one, please see the other
> thread.
Sorry about that.
> However, I think you might really want this:
> when: a is defined and a.stat.isfile
> OR (depending on use case)
> when: a is defined and not a.stat.isfile
>
> Maybe try one of those first...
I played with that code where /usr/local/bin/python3.4 does not exist :
#####################################
- name: Verify if Python 3.4 is installed
stat: path=/usr/local/bin/python3.4
register: l
- debug: msg=execute
when: l is defined
#####################################
And :
l is defined : trigger the debug message
l is not defined : skipping
l is defined and l.stat.isfile : skipping
l is defined and not l.stat.isfile : skipping
l is not defined and l.stat.isfile : skipping
l is not defined and not l.stat.isfile : skipping
This is executed on localhost, with root privileges.
I actually find that weird as if it functions like stat on linux,
IMU l shouldn't be defined at all, no ?
Thanks.