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].
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/c6f4ab7d-40bf-4eb8-850a-19a00ee6fd71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to