Interesting Uses of Ansible’s ternary filter
Some time ago I discovered an interesting use of the ternary-filter in Ansible.
A ternary-filter in Ansible is a filter that takes three arguments: a condition, a value if the condition is true and an alternative value if the condition is false.
Here’s a simple example straight from Ansible’s documentation:
- name: service-foo, use systemd module unless upstart is present, then use old service module
service:
state: restarted
enabled: yes
use: "{{ (ansible_service_mgr == 'upstart') | ternary('se...
Read more at zufallsheld.de