cloudalchemy / ansible-grafana

Platform for analytics and monitoring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to load LDAP config file when using Jinja templated integer variable

xpacm opened this issue · comments

When a Jinja templated variable is used as LDAP port value like this:

grafana_ldap:
  servers:
    host: "{{ ldap_server_name }}"
    port: "{{ ports.ldap }}"

this is parsed as a string in ldap.toml, resulting in the following error:

t=2019-09-06T14:26:47+0200 lvl=eror msg="Error while trying to authenticate user" logger=context userId=0 orgId=0 uname= error="Failed to get LDAP config: Failed to load LDAP config file: toml: cannot load TOML value of type string into a Go integer"

Possible solution:

in ldap.toml.j2

{% for k,v in grafana_ldap.servers.items() if k != 'attributes' %}
{%   if k == 'port' %}
{{ k }} = {{ v | int }}
{%   elif v in [True, False] %}
{{ k }} = {{ 'true' if v else 'false' }}
{%   else %}
{{ k }} = {{ v | to_nice_json }}
{%   endif %}
{% endfor %}
commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sorry, this flew under the radar. Your fix seems good and I included it in #180.

commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.