Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

cast grafana_port to int before comparing it to 1024 #212

Closed
kapouer opened this issue Mar 30, 2020 · 3 comments
Closed

cast grafana_port to int before comparing it to 1024 #212

kapouer opened this issue Mar 30, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@kapouer
Copy link
Contributor

kapouer commented Mar 30, 2020

What happened?

The conditional check 'grafana_port <= 1024' failed.
The error was: Unexpected templating type error occurred on ({% if grafana_port <= 1024 %} True {% else %} False {% endif %}): '<=' not supported between instances of 'str' and 'int'
The error appears to be in '/home/dev/.ansible/roles/cloudalchemy.grafana/tasks/preflight.yml': line 80

Did you expect to see some different?
grafana_port should be settable using jinja templates.

How to reproduce it (as minimally and precisely as possible):

  • set_fact: myport=9999
    ...
    grafana_port: "{{ myport }}"

Environment
debian/sid

  • Role version:
    0.16.2

  • Ansible version information:
    2.9.6

  • What else ? *

I tried to use the | int filter but it won't work. "Jinja always output strings".

@kapouer kapouer added the bug Something isn't working label Mar 30, 2020
@paulfantom
Copy link
Member

Probably needs altering this line: https://github.com/cloudalchemy/ansible-grafana/blob/master/templates/grafana.ini.j2#L20 Could you create a PR and test it?

kapouer added a commit to kapouer/ansible-grafana that referenced this issue Mar 30, 2020
@kapouer
Copy link
Contributor Author

kapouer commented Mar 30, 2020

No that won't work: the check is in a task, not in a template.

@kapouer
Copy link
Contributor Author

kapouer commented Mar 30, 2020

But let me PR this another way

kapouer added a commit to kapouer/ansible-grafana that referenced this issue Mar 30, 2020
cosandr pushed a commit to cosandr/ansible-grafana that referenced this issue Aug 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants