I might be misinformed but I believe that syntax will be deprecated soon
and the best way to write that conditional is:
when: '{{ was }}' == 'jboss'
On Thursday, March 17, 2016 at 5:08:52 PM UTC-5, Brian Coca wrote:
>
> you are writing your conditionals wrong, vars don't need {{}} and strings
> need quoting:
>
> when: was == 'jboss'
>
> On Wed, Mar 16, 2016 at 8:23 PM, NEW HOMIE <[email protected]
> <javascript:>> wrote:
>
>> Hello there~
>> Is this possible using when conditional with variables?
>>
>> For instance, I use two kind of was (Jboss, Weblogic)
>>
>> I create for checking process id some yml files like under line
>>
>> *check.yml*
>> - shell: ps -ef | grep '{{ nodename }}' | grep XX | awk {'print $2'}
>> register: pid
>> ignore_errors: True
>> when: {{ was }} == jboss
>>
>> - shell: /usr/ucb/ps -auxwww | grep '{{ nodename }}' | grep XX | awk
>> {'print $2'}
>> register: pid
>> ignore_errors: True
>> when: {{ was }} == weblogic
>>
>>
>> and then, put this yml file in main.yml
>>
>> *main.yml*
>> - include: check.yml
>> tags: check
>>
>> now I would execute this command
>>
>> # ansible-playbook playbook -i inventory -t check -e
>> component=somecomponent -e nodename=somenodename -e was=jboss
>>
>>
>> however It gives me under error message?
>> {"failed": true, "reason": "ERROR! Syntax Error while loading YAML.
>> The error appears to have been in 'check.yml': line 5, column 19, but
>> maybe elsewhere in the file depending on the exact syntax problem.
>> The offending line appears to be: ignore_errors: True\n when: {{ was }}
>> == jboss^ here
>> We could be wrong, but this one looks like it might be an issue with
>> missing quotes.
>> Always quote template expression brackets when they start a value. For
>> instance: with_items: - {{ foo }} Should be written as: with_items: - \"{{
>> foo }}\""}
>>
>>
>> What's problem in my check.yml??
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/c6f4ab7d-40bf-4eb8-850a-19a00ee6fd71%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/c6f4ab7d-40bf-4eb8-850a-19a00ee6fd71%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> ----------
> Brian Coca
>
--
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/1ca1c0cf-6a7c-4918-8791-2823c34d693c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.