I think you are misunderstanding the return codes of the stat module.

When the file is not there, it doesn't register a "None" in the file
location.

Insert this line, and you'll see what I mean:

- debug: var=I

I would also recommend naming variables something other than "I", for
readability purposes.   python34 would be a good variable name :)






On Sun, Jul 27, 2014 at 7:46 AM, 'Diogene Laerce' via Ansible Project <
[email protected]> wrote:

>
>
> 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.
> --
> “One original thought is worth a thousand mindless quotings.”
> “Le vrai n'est pas plus sûr que le probable.”
>
>                                               Diogene Laerce
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgwJ%3Dji9aDQm5CcuB4cMTVnoKm40Obh7eJ8FKjkDgArPcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to