grafana-service

Example:

# Install Grafana and add a Prometheus datasource and a matching dashboard.
- grafana-service:
    admin_password: password123
    listen_url: http://192.168.1.11:3000
    datasources:
    - name: prometheus
      type: prometheus
      access: proxy
      url: http://192.168.1.12:9090
      basic_auth: false
    dashboards:
    - dashboard_id: 1860
      revision_id: 12
      datasource: prometheus

Description

n/a

Resources

Variables

Name Type Default Description

admin_password

string --

The name of the default Grafana admin user (who has full permissions). Required

listen_url

string --

Full URL used to access Grafana from a web browser. Required

admin_user

string admin

The name of the admin user.

alerting_config

dict --

'alerting' configuration section.

Defaults to:

true

analytics_config

dict --

'analytics' configuration section.

Defaults to:

{}

auth_config

dict --

'auth' configuration section.

Defaults to:

{}

dashboard_dir

string --

Path to a local directory containing dashboards files in json format.

Defaults to 'dashboards'.

dashboards

list --

List of dashboards which should be imported.

Example:

- dashboard_id: 111
  revision_id: 1
  datasource: prometheus

data_source_proxy_whitelist

string --

White list of allowed ips/domains to use in data sources.

Format: ip_or_domain:port separated by spaces.

database_config

dict --

'database' configuration section.

Defaults to:

{
  type: sqlite3
}

datasources

list --

List of datasources which should be configured.

Example:

- name: prometheus
  type: prometheus
  access: proxy
  url: 'http://{{ prometheus_web_listen_address }}'
  basicAuth: false

disable_gravatar

boolean --

Whether to disable gravatar for user profile images.

Set to true to disable the use of Gravatar for user profile images. Default is false.

email_on_sign_up

boolean --

Send welcome email after signing up.

environment

dict --

Optional Environment param for Grafana installation, usefull ie for setting http_proxy.

image_storage_config

dict --

'image_storage' configuration section.

Defaults to:

{}

instance_name

string --

The grafana instance name.

Defaults to:

{{ ansible_fqdn | default(ansible_host) | default(inventory_hostname) }}

ldap_config

dict --

'ldap' configuration section.

Defaults to:

{}

listen_address

string --

The address the grafana service listens on.

Defaults to: '0.0.0.0'

listen_port

integer --

The port the grafana service listens on. Defaults to 3000.

login_remember_days

integer --

The number of days the keep me logged in / remember me cookie lasts.

metrics_config

dict --

'metrics' configuration section.

Defaults to:

{}

secret_key

string --

Secret key.

Used for signing some datasource settings like secrets and passwords. Cannot be changed without requiring an update to datasource settings to re-encode them.

server_config

dict --

'server' configuration section.

Defaults to:

{
  protocol: http,
  enforce_domain: false,
  socket: "",
  cert_key: "",
  cert_file: "",
  enable_gzip: false,
  static_root_path: public,
  router_logging: false
}

session_config

dict --

'session' configuration section.

Defaults to:

{}

smtp_config

dict --

'smtp' configuration section.

Defaults to:

{}

snapshots_config

dict --

'snapshots' configuration section.

Defaults to:

{}

tracing_config

dict --

'tracing' configuration section.

Defaults to:

{}

users_config

dict --

'users' configuration section.

Defaults to:

{
  allow_sign_up: false,
  auto_assign_org_role: Viewer,
  default_theme: dark
}

version

string --

The grafana version. Defaults to 'latest'.

Examples

Example 1

Install Grafana and add a Prometheus datasource and a matching dashboard.

Code
- grafana-service:
    admin_password: password123
    listen_url: http://192.168.1.11:3000
    datasources:
    - name: prometheus
      type: prometheus
      access: proxy
      url: http://192.168.1.12:9090
      basic_auth: false
    dashboards:
    - dashboard_id: 1860
      revision_id: 12
      datasource: prometheus
Description

Check out the freckles security docs if you are concerned about providing the password in plain text.

Command-line

frecklecute grafana-service --help

Usage: frecklecute grafana-service [OPTIONS]

  Installs the grafana service.

Options:
  --admin-password ADMIN_PASSWORD
                                  The password of the default Grafana admin.
                                  [required]
  --listen-url LISTEN_URL         The full url to access this grafana
                                  instance.  [required]
  --admin-user ADMIN_USER         The name of the admin user.  [default:
                                  admin]
  --alerting-config ALERTING_CONFIG
                                  alerting config
  --analytics-config ANALYTICS_CONFIG
                                  analytics config
  --auth-config AUTH_CONFIG       auth config
  --dashboard-dir DASHBOARD_DIR   Path to a local directory containing
                                  dashboards files.
  --import-dashboard DASHBOARD    List of dashboards which should be imported.
  --data-source-proxy-whitelist DATA_SOURCE_PROXY_WHITELIST
                                  White list of allowed ips/domains to use in
                                  data sources.
  --database-config DATABASE_CONFIG
                                  database config
  --datasources DATASOURCES       List of datasources which should be
                                  configured.
  --disable-gravatar / --no-disable-gravatar
                                  Whether to disable gravatar for user profile
                                  images.
  --email-on-sign-up / --no-email-on-sign-up
                                  Send welcome email after signing up.
  --environment ENVIRONMENT       Optional Environment parameters for Grafana
                                  installation.
  --image-storage-config IMAGE_STORAGE_CONFIG
                                  image_storage config
  --instance-name INSTANCE_NAME   The grafana instance name.
  --ldap-config LDAP_CONFIG       ldap config
  --listen-address LISTEN_ADDRESS
                                  The address the service listens on.
  --listen-port LISTEN_PORT       The port the service listens on.
  --login-remember-days LOGIN_REMEMBER_DAYS
                                  The number of days the keep me logged in /
                                  remember me cookie lasts.
  --metrics-config METRICS_CONFIG
                                  metrics config
  --secret-key SECRET_KEY         Secret key.
  --server-config SERVER_CONFIG   server config
  --session-config SESSION_CONFIG
                                  session config
  --smtp-config SMTP_CONFIG       smtp config
  --snapshots-config SNAPSHOTS_CONFIG
                                  snapshots config
  --tracing-config TRACING_CONFIG
                                  tracing config
  --users-config USERS_CONFIG     users config
  --version VERSION               The grafana version.
  --help                          Show this message and exit.