Ensure values are cast to correct type

https://github.com/willshersystems/ansible-sshd/issues/188
This shouldn't be necessary, but there seems no way to
guarantee using a version of Jinja which doesn't have this
problem.

In addition - it is not good practice to compare values to
`true` or `false` - instead, just ensure the value is a `bool`
type and evaluate in a boolean context.
This commit is contained in:
Rich Megginson 2022-08-11 10:47:46 -06:00 committed by Jakub Jelen
parent 9766d9097a
commit 67d2339f03
3 changed files with 5 additions and 5 deletions

View file

@ -7,10 +7,10 @@
{% elif value is sameas false %}
{{ key }} no
{% elif value is string or value is number %}
{{ key }} {{ value }}
{{ key }} {{ value | string }}
{% else %}
{% for i in value %}
{{ key }} {{ i }}
{{ key }} {{ i | string }}
{% endfor %}
{% endif %}
{% endif %}

View file

@ -6,10 +6,10 @@
{% elif value is sameas false %}
{{ key }} no
{% elif value is string or value is number %}
{{ key }} {{ value }}
{{ key }} {{ value | string }}
{% else %}
{% for i in value %}
{{ key }} {{ i }}
{{ key }} {{ i | string }}
{% endfor %}
{% endif %}
{% endif %}

View file

@ -1,6 +1,6 @@
{{ ansible_managed | comment }}
{% if __sshd_sysconfig_supports_crypto_policy %}
{% if sshd_sysconfig_override_crypto_policy == true %}
{% if sshd_sysconfig_override_crypto_policy | bool %}
CRYPTO_POLICY=
{% endif %}
{% endif %}