Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update grafana template #300

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions roles/grafana/templates/grafana.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
# http://docs.grafana.org/installation/configuration
# https://github.com/grafana/grafana/blob/master/conf/sample.ini

{% for k, v in grafana_ini.items() %}
{% if v is not mapping %}
{{ k }} = {{ v }}
{% endif %}
{% endfor %}

santilococo marked this conversation as resolved.
Show resolved Hide resolved
{% for section, items in grafana_ini.items() %}
{% if items is mapping %}
[{{ section }}]
{% for k,v in items.items() %}
{% for sub_key, sub_value in items.items() %}
{% if sub_value is mapping %}

[{{ section }}.{{ sub_key }}]
{% for k, v in sub_value.items() %}
{{ k }} = {{ v }}
{% endfor %}

{% else %}
{{ sub_key }} = {{ sub_value }}
{% endif %}
{% endfor %}
{% else %}
{{ section }} = {{ items }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or can sectionless keys be set here if item is not mapping?

They need to be at the top before any sections to be sectionless. I don't suppose the not mapping items are guaranteed to be iterated first?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. Sectionless items like instance_name and app_mode will be included in the last else statement. Your last sentence is correct. Currently, if you place them at the top of your YAML file, they will be guaranteed to appear first. However, if you place them at the end, they will not. We should revert this part to the previous if logic. I will open a new MR to address this issue. Thank you for identifying this edge case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{% endif %}

{% endfor %}
Loading