Even though a task is skipped, the registered variable is still created.
You would want to check something like the following on your "test 2" task
instead:

when: not test_1|skipped

On Wed, Mar 11, 2015 at 10:06 AM, Marc Patermann <
hans.mo...@ofd-z.niedersachsen.de> wrote:

> Hi,
>
> should this work:
>
>   tasks:
>   - name: test
>     shell: uname -a
>     when:  env == "test"
>
>   - name:  test 1
>     file: path=/opt/test.txt state=touch
>     when: env == "test1"
>     register: test_1
>
>   - name: test 2
>     file: path=/opt/test2 state=touch
>     when: test_1 is defined
>
>
> Task "test 1" should run, if some conditional is true.
> Depending on if it runs, task "test 2" should run.
> That's why i registered a variable test_1.
>
> The result is, that "test 1" ist skipped", because env != "test" (as
> expected; OK). But "test 2" does run too.
>
> I could use a handler, but that does only run after all the tasks, which
> why I have to change the running order. Is there another way?
>
>
> Marc
>
> --
> 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/55005A0C.2010707%40ofd-z.niedersachsen.de.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
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_jfWNCm5hOt37jp8muw%3DBAL0MPcmjunD1rrRpoFO1%2BJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to