-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ternary() filter does not appear to work as documented #10763
Comments
Yes! I was running into this too: - docker:
image: "company/tv-server:{{ item }}-latest"
links:
- "{{ 'production' in node_envs | ternary('foo' + item, omit) }}"
with_items: node_envs
|
Take a look at #10767 I've submitted a pull request to update the docs. @candlerb, what you need is: The addition is the |
That works, thank you. I found there is an open bug on jinja2 for not documenting operator precedence. I believe that it implicitly uses the same operator precedences as python, which would be reasonable, except that jinja2 uses the pipe operator for applying filters to expressions, not bitwise-OR of its operands. |
Correct the ternary example. Fixes #10763
Issue Type:
Bug Report
Ansible Version:
Environment:
OSX 10.9.5
Summary:
The ternary() filter does not appear to work as documented
Steps To Reproduce:
Use this playbook:
Expected Results:
That the variables foo and bar would be set to either "Mr" or "Mrs". Instead they are set to the string "False"
Actual Results:
The text was updated successfully, but these errors were encountered: