nut: Encrypt upsd user passwords with age

Switching from Ansible Vault to age.

I've changed the `upsd.users` template somewhat in order to handle the
`password` property separately.  Now, items in the `nut_users` list
are objects with properties instead of lists of objects with properties.
The latter was done to support repeating options (`actions` and
`instcmds`), but that is more appropriately handled with lists of
values.

This value is encrypted with the following public key:

    age1c6swn9tm0502jd3e0yszfd4qd7lgx2nd9uk0hruuckhx7zpn3utqhau7mz
This commit is contained in:
2024-01-09 17:25:42 -06:00
parent fefa8f6a23
commit 8b7b7b677d
3 changed files with 20 additions and 13 deletions

View File

@@ -1,8 +1,15 @@
{% for username, settings in nut_users.items() %}
[{{ username }}]
{% for setting in settings %}
{% for key, value in setting|dictsort %}
{{ key }} = {{ value }}
{% if settings.password|d(none) is not none %}
password = {{ settings.password | decrypt }}
{% endif %}
{% for action in settings.actions|d([]) %}
actions = {{ action }}
{% endfor %}
{% for instcmds in settings.instcmds|d([]) %}
instcmds = {{ instcmds }}
{% endfor %}
{% if not loop.last %}
{% endif %}
{% endfor %}