I believe you'd want to check whether the registered variable (or member of
the variable) is defined, as follows (assuming you registered a variable
named result):

when: '"foo" in result and result.foo != "something"'

This way, you can prevent undefined errors and the task would just be
skipped.



On Thu, May 22, 2014 at 10:20 AM, Marc Petrivelli <[email protected]
> wrote:

> Variables that are brought into scope through the "register: var" when a
> task is executed are not available when a playbook is run with the --check
> mode.
>
> The work-around I have been using is to put defaults (for all those
> variables that will eventually be brought into scope using register) using
> set_fact or group_vars/all or an included var file.
>
> I suggest changing the ansible --check mode to not evaluate those
> variables, in the when clause, normally brought into scope using register.
>
> Does anyone else have this problem?  Did you use another work around? Do
> you like my idea of selectively evaluating variables that are "registered"?
>
>
>
>  --
> 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/b37591be-6ff8-4a25-99a9-eb24ef5a924b%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/b37591be-6ff8-4a25-99a9-eb24ef5a924b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMFyvFj9oBvSScP_uuHpc1CMQFWt3oLQ93mJ0kGEeHbwqD%3DxvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to