Reputation: 24298
I have a playbook which I execute with:
ansible-playbook -i inventories/staging/ myPlaybook.yml -e "srv_mode=restart"
The variable srv_mode
is used in a play. Now I only want to allow "restart" and "start" as its values.
Is there a possibility to evaluate the content of srv_mode
at first and to end gracefully with a nice warning in case the value is not supported?
Upvotes: 0
Views: 1184
Reputation: 68559
Use assert
module, optimally in a separate play at the top of your playbook:
- hosts: localhost
connection: local
gather_facts: false
pre_tasks:
- assert:
that: srv_mode in ['start', 'restart']
Upvotes: 5