Let's say I have a group var named show_canada
which is a boolean. I have the following task:
- name: install conf file
template: src="example.conf.j2" dest="/etc/{{ item }}/example.conf"
sudo: yes
with_items:
- usa
- brazil
- canada
- japan
- turkey
How can I have the task skip the canada item depending on the value of the show_canada boolean? I guess I can have a when
field that checks if the item == 'canada' and show_canada is true? There has to be a better/nicer way to accomplish this, any suggestions? And if I have multiple tasks that require this same filtering, is there some global way I can skip certain items?
In those cases what I'm doing is including status with the value in a dict:
You even probably can set the display value from a var