dmaes / ansible-role-vaultwarden

Builds, installs and configures Bitwarden_RS (https://github.com/dani-garcia/bitwarden_rs) (without Docker)
https://galaxy.ansible.com/dmaes/bitwardenrs
MIT License
9 stars 7 forks source link

Update env.j2 #9

Closed JensTimmerman closed 3 years ago

JensTimmerman commented 3 years ago

fixes no test named boolean

fatal: [bitwarden]: FAILED! => {"changed": false, "msg": "AnsibleError: template error while templating string: no test named 'boolean'. String: {{ ansible_managed|comment }}\n{{ _bitwardenrs_ansible_managed|comment }}\n\n## Bitwarden_RS Configuration File\n\n{% for key, value in bitwardenrs_config.items() %}\n{% if value is boolean %}\n{{ key }}={{ 'true' if value else 'false' }}\n{% elif value is number %}\n{{ key }}={{ value }}\n{% else %}\n{{ key }}=\"{{ value }}\"\n{% endif %}\n{% endfor %}\n"}
dmaes commented 3 years ago

According to https://jinja.palletsprojects.com/en/2.11.x/templates/#list-of-builtin-tests boolean should be a valid test since 2.11. What version of jinja2 are you using?

IDK if Rust would treat it any different, but AFAIK VAR="True" and VAR="False" (which current fix would result to) are not valid booleans, only VAR=true and VAR=false are (not even VAR=True and VAR=False, could be wrong though, but that is what some quick testing tells me at least.)

JensTimmerman commented 3 years ago
>>> import jinja2
>>> jinja2.__version__
'2.10.1'
[root@ansible ansible]# sudo dnf install python3-jinja2
Last metadata expiration check: 2:42:37 ago on Fri Mar 12 10:11:19 2021.
Package python3-jinja2-2.10.1-2.el8_0.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!

it's the latest one in centos8

pip3 install jinja2 -U fixes this, but now I need to make sure to keep this version up to date since my os isn't going to fix security issues in it...

dmaes commented 3 years ago

If that is workable for you, we could leave it at that then, else we could maybe do a 'if == true or == false' instead of is boolean (with a 'why' comment), should give the same result, I think. If we leave it as is and you use jinja2 from pip, then I'll add jinja v2.11 as dependency in readme (and meta/main.yml if there is a key for that? idk)

JensTimmerman commented 3 years ago

works for me for now.