Hello,
I am trying to do some special jobs only for some hosts.
My setup until now: One playbook, which creates dynamic groups and includes different roles based on the dynamic groups (e.g. common for all hosts, or Suse-11-x86_64)
This Suse-role should now have an include like this:
- include: sap-appl.yml tags=sap-appl
when: sap_appli == “yes”
The variable sap_appli is self-defined for every host. I tried 2 methods
a) defining it inside the inventory, e.g.
myHost001 sap_appli=yes
b) writing host_vars in a seperate folder
cat host_vars/myHost001
sap_appli: yes
Both methods have the same effect. It works for hosts with sap_appli defined. But if this variable is not defined, the playbook-run crashes:
fatal: [gisu951] => Conditional expression must evaluate to True or False: (True) and ({% if sap_appli == “yes” %} True {% else %} False {% endif %})
Is it possible to define a default value?
In my case now:
sap_appli=no
Using a file host_vars/all doesn’t have any effect. Including an special vars_file with the default value overwrites every host-defined variable.
Thanks for your help,
best regards
Alex