ansible-collection-prometheus/roles/mysqld_exporter/templates/web_config.yaml.j2
Ilari Iso-Junno 9812360144 enhancement: support ansible-vaulted basic auth passwords
If ansible-vaulted password is passed to password_hash filter, it will throw and error:
'secret must be unicode or bytes, not ansible.parsing.yaml.objects.AnsibleVaultEncryptedUnicode'
Handling the vaulted password with string filter first will avoid the problem.

Signed-off-by: Ilari Iso-Junno <iisojunn@users.noreply.github.com>
2023-04-12 10:45:46 +03:00

18 lines
697 B
Django/Jinja

---
{{ ansible_managed | comment }}
{% if mysqld_exporter_tls_server_config | length > 0 %}
tls_server_config:
{{ mysqld_exporter_tls_server_config | to_nice_yaml | indent(2, true) }}
{% endif %}
{% if mysqld_exporter_http_server_config | length > 0 %}
http_server_config:
{{ mysqld_exporter_http_server_config | to_nice_yaml | indent(2, true) }}
{% endif %}
{% if mysqld_exporter_basic_auth_users | length > 0 %}
basic_auth_users:
{% for k, v in mysqld_exporter_basic_auth_users.items() %}
{{ k }}: {{ v | string | password_hash('bcrypt', ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' | shuffle(seed=inventory_hostname) | join)[:22], rounds=9) }}
{% endfor %}
{% endif %}