Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if strings are equals and ternary operator in Ansible

Tags:

ansible

jinja2

In my playbook, I have this:

#More things - include: deploy_new.yml   vars:     service_type: "{{ expose_service == 'true' | ternary('NodePort', 'ClusterIP') }}"     when: service_up|failed 

When expose_service is true, I want service_type to be set to NodePort, and ClusterIP otherwise.

However, service_type is set to False in all cases.

What am I doing wrong?

like image 763
Héctor Avatar asked May 11 '16 11:05

Héctor


1 Answers

Solved!

service_type: "{{ 'NodePort' if expose_service == 'true' else 'ClusterIP' }}" 
like image 71
Héctor Avatar answered Sep 20 '22 02:09

Héctor