What is happening is that you are effectively setting foo to the string
"false"

What you likely want to do is:

    when: not foo|bool

On Wednesday, August 13, 2014, Michael Peters <michael00pet...@gmail.com>
wrote:

> Before I file a ticket, I just want to make sure I'm not doing
> anything wrong. BTW, this is a simplified example to reproduce the
> problem, not what I was actually trying to do.  I have this simple
> playbook test.yml:
>
> ---
> - hosts: 127.0.0.1
>   connection: local
>   tasks:
>   - set_fact: foo=false
>
>   - command: ls /
>     when: not foo
>
> Executed like this:
>
> ansible-playbook -i '127.0.0.1,' test.yml
>
>
> Which results in the following output:
> PLAY [127.0.0.1]
> **************************************************************
>
> GATHERING FACTS
> ***************************************************************
> ok: [127.0.0.1]
>
> TASK: [set_fact foo=false]
> ****************************************************
> ok: [127.0.0.1]
>
> TASK: [command ls /]
> **********************************************************
> skipping: [127.0.0.1]
>
> Notice the last task is skipped. So for some reason it's not following
> the logic of the when clause like I'd expect. But the really weird
> thing is that if I change the task to say "when: foo" (reverse the
> logic) I get the same output:
>
> ---
> - hosts: 127.0.0.1
>   connection: local
>   tasks:
>   - set_fact: foo=false
>
>   - command: ls /
>     when: foo
>
> Executed like this: ansible-playbook -i '127.0.0.1,' test.yml
>
> PLAY [127.0.0.1]
> **************************************************************
>
> GATHERING FACTS
> ***************************************************************
> ok: [127.0.0.1]
>
> TASK: [set_fact foo=false]
> ****************************************************
> ok: [127.0.0.1]
>
> TASK: [command ls /]
> **********************************************************
> skipping: [127.0.0.1]
>
> Same output. So even if something with my logic was wrong (for
> instance set_fact didn't like the literal "false") you would still
> think that taking out the "not" would result in the task being
> executed.
>
> ansible 1.8 (devel 9edf3a749a) last updated 2014/08/13 14:03:10 (GMT +000)
>
> Am I doing something wrong? Or should I file a bug report?
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com <javascript:;>.
> To post to this group, send email to ansible-project@googlegroups.com
> <javascript:;>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAJQqANdAt%3D3PB30cEDMqknJHY%2BAr3VwpxePrgN4J-dvfeZUWGQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Matt Martz
m...@sivel.net
http://sivel.net/

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v_XppVmJ_%3DzxCn7NrbbyAOjLueX%2BqJz%2Ba23nQq62vTJBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to