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

Support mysql session backend #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
28 changes: 18 additions & 10 deletions grafana/files/grafana.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ http_addr = {{ server.bind.address }}
http_port = {{ server.bind.port }}

# The public facing domain name used to access grafana from a browser
;domain = localhost
domain = {{ server.get('domain', 'localhost') }}

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
;enforce_domain = false

# The full public facing url
;root_url = %(protocol)s://%(domain)s:%(http_port)s/
root_url = {{ server.get('root_url', '%(protocol)s://%(domain)s:%(http_port)s/') }}

# Log web requests
;router_logging = false
Expand Down Expand Up @@ -85,6 +85,10 @@ provider = {{ server.session.engine }}
provider_config = addr={{ server.session.get('host', '127.0.0.1') }}:{{ server.session.get('port', 6379) }},db={{ server.session.get('db', 'grafana') }}
{%- endif %}

{%- if server.session.engine == 'mysql' %}
provider_config = {{ server.session.get('user', 'grafana') }}:{{ server.session.get('password', 'grafana') }}@tcp({{ server.session.get('host', '127.0.0.1') }}:{{ server.session.get('port', 3306) }})/{{ server.session.get('db', 'grafana') }}
{%- endif %}

# Session cookie name
;cookie_name = grafana_sess

Expand Down Expand Up @@ -181,15 +185,19 @@ org_name = {{ server.auth.role }}

#################################### Google Auth ##########################
[auth.google]
{%- if server.auth.google.get('enabled') %}
enabled = true
allowed_domains = {{ server.auth.google.get('allowed_domains', '') }}
allow_sign_up = {{ server.auth.google.get('allow_sign_up', 'false') }}
client_id = {{ server.auth.google.get('client_id', '') }}
client_secret = {{ server.auth.google.get('client_secret', '') }}
scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
auth_url = https://accounts.google.com/o/oauth2/auth
token_url = https://accounts.google.com/o/oauth2/token
api_url = https://www.googleapis.com/oauth2/v1/userinfo
{%- else %}
;enabled = false
;allow_sign_up = false
;client_id = some_client_id
;client_secret = some_client_secret
;scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
;auth_url = https://accounts.google.com/o/oauth2/auth
;token_url = https://accounts.google.com/o/oauth2/token
;api_url = https://www.googleapis.com/oauth2/v1/userinfo
;allowed_domains =
{%- endif %}

#################################### Auth Proxy ##########################
[auth.proxy]
Expand Down
9 changes: 9 additions & 0 deletions grafana/server.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{%- from "grafana/map.jinja" import server with context %}
{%- if server.enabled %}

grafana package repository:
Copy link
Contributor

Choose a reason for hiding this comment

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

There should at least be a flag in the pillar to enable or not the Grafana repository. Or it could be managed with additional service metadata like for InfluxDB or Elasticsearch.

pkgrepo.managed:
- name: deb https://packagecloud.io/grafana/stable/debian/ {{ grains["oscodename"] }} main
- keyid: 418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB
- keyserver: hkp://p80.pool.sks-keyservers.net:80
- file: /etc/apt/sources.list.d/grafana.list
- refresh_db: True

grafana_packages:
pkg.installed:
- names: {{ server.pkgs }}
- pkgrepo: grafana package repository

/etc/grafana/grafana.ini:
file.managed:
Expand Down