Sample Header Ad - 728x90

In Ansible, how to check if variable value has three options? Ternary operator works only for two options

0 votes
2 answers
3443 views
When mount point /dev/backboot is >70%, set to "High", and if < 70%, set to "Normal", and if there is no such mount point at all, then set to "not available". The example below works fine with two options, but I need three. Can you suggest?
- name: get usage
  command: df -k | grep -i /dev/backboot | awk '{print $5}'
  register: usage
Here, the output of registered value usage.stdout is 67% as an example:
- name: Set the value
  set_fact:
     mspace: "{{ (usage.stdout | int < 80) | ternary('Normal','High') }}"
Asked by Sandhya S (1 rep)
May 18, 2021, 07:21 AM
Last activity: Jun 5, 2025, 09:05 PM