Open OrangeDog opened 5 years ago
As a workaround, you can set them as a string instead: startagents: '0'
It's a common issue. I think it's nothing to fix in formula, 0
without quotes i.e when it represent a number will interpret as False at Python / Jinja level. Personally I got into the habit of using quotes in yaml if I want something like0|1
, yes|no
or true|false
to be used as a string.
@OrangeDog do you think on formula side all variables mut be forced to string type?
How about adding this specific value to pillar.example
? Also, fixing any other examples in that file?
Or have the template check the actual value instead of letting it cast to boolean.
Sorry but I don't understand what do you mean by
have the template check the actual value instead of letting it cast to boolean.
Template render line with the option only if option value not empty string, None
or False
https://github.com/saltstack-formulas/zabbix-formula/blob/b83c7a02ae465baca17063aa9b83a84ff2d93d9e/zabbix/files/default/etc/zabbix/zabbix_server.conf.jinja#L305-L310
Python / Jinja interprets numeric zero 0
as False
so it's required to convert value to string type to evaluate 0
as True
. But this will require rewrite of all condition expressions in all template files in this formula.
OR
User can just quote values when they expeted to be string type.
{% if settings.get('startalerters', defaults.get('startalerters', False)) == False -%}
For example,
startagents: 0
will not work, because the template will omit the section because it's falsy.