Reputation: 63
When formatting variables in ansible playbooks which format should be followed? I cannot for the life of me find a straight answer for this?
environment:
- http_proxy: "{{ {{ proxy }} if {{ proxy }} != '' else {{ ansible_local.proxy_facts.proxy }} }}"
- http_proxy: "{{ proxys if proxy != '' else ansible_local.proxy_facts.proxy }}"
Upvotes: 0
Views: 42
Reputation: 68074
Use ternary
filter. For example
- set_fact:
http_proxy: "{{ (proxy|length > 0)|
ternary(proxy, ansible_local.proxy_facts.proxy) }}"
Upvotes: 1