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

grafana.ini yaml syntax #232

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

intermittentnrg
Copy link

Untested draft for early feedback of #210.

I've done search&replace to use new convention for grafana_ini: var.
I did not expect there to be 19 changed files, but there were many references for example to grafana_url which is now grafana_ini.server.root_url and similar.

I kept all entries in README and defaults/main.yaml, but I think most should be deleted. Repeating grafana documentation and default values doesn't make sense. The default grafana.ini is empty/everything commented out, we should let grafana handle defaults.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ishanjainn
Copy link
Member

cc @gardar

@intermittentnrg
Copy link
Author

I reviewed all vars to discover which are not used in role and can be descoped/deferred to grafana docs.

Vars used in role:

old new purpose
grafana_instance grafana_ini.instance_name default value from ansible
grafana_logs_dir grafana_ini.paths.logs mkdir
grafana_data_dir grafana_ini.paths.data provisioning dashboards & plugins
grafana_address grafana_ini.server.http_addr default for root_url
grafana_port grafana_ini.server.http_port default for root_url and validate cap_net_bind_service
grafana_url grafan_ini.server.root_url default for grafana_api_url
grafana_domain grafana_ini.server.domain default value from ansible
grafana_server grafana_ini.server create socket if protocol == 'socket
grafana_security grafana_ini.security admin_user and admin_password for api calls
grafana_database grafana_ini.database validate correct keys for type =/!=sqlite3
grafana_auth grafana_ini.auth configure ldap if ldap.enabled
grafana_users grafana_ini.users allow_sign_up=false and default_theme=dark differ from grafana defaults

Vars not used in role - removed from README.md and defaults/main.yaml in 2nd commit

old new note
grafana_users grafana_ini.users
grafana_welcome_email_on_sign_up grafana_ini.emails.welcome_email_on_sign_up
grafana_session grafana_ini.session
grafana_analytics grafana_ini.analytics
grafana_smtp grafana_ini.smtp
grafana_alerting grafana_ini.alerting
grafana_log grafana_ini.log
grafana_metrics grafana_ini.metrics
grafana_tracing grafana_ini."tracing.jaeger"
grafana_snapshots grafana_ini.snapshots
grafana_image_storage grafana_ini.image_storage
grafana_date_formats grafana_ini.date_formats
grafana_feature_toggles grafana_ini.feature_toggles
grafana_remote_cache grafana_ini.remote_cache undocumented
grafana_auth_generic_oauth grafana_ini."auth.generic_oauth" undocumented
grafana_panels grafana_ini.panels undocumented, no defaults

Removed hardcoded sections in grafana.ini.j2 (could submit these as a separate PR, everything else is intertwined)

section note
[dashboards] hardcoded, grafana defaults
[dashboards.json] hardcoded, replaced by dashboards provisioning in grafana 5.0+
[grafana_com] hardcoded, grafana defaults

@ishanjainn
Copy link
Member

This is superb! Thanks @intermittentnrg

LGTM, ill wait for sometime if @gardar want to review it and then merge

@intermittentnrg
Copy link
Author

Finally got around to testing this.

The dict grafana_ini gets overwritten and not inherited from defaults/main.yaml.
I renamed it to grafana_ini_default and added this task in tasks/main.yaml:

ansible.builtin.set_fact:
  grafana_ini: "{{ grafana_ini_default | ansible.builtin.combine(grafana_ini, recursive=true) }}"

Also this line no longer works as it refers to itself. So just set this explictly.
http_addr defaults to 0.0.0.0 which is not valid.

grafana_ini:
  server:
    root_url: "http://{{ grafana_ini.server.http_addr }}:{{ grafana_ini.server.http_port }}"

I rebased and force pushed to fix conflicts.

@intermittentnrg intermittentnrg marked this pull request as ready for review August 3, 2024 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants