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
Installs the grafana service.
Resources
Variables
Name | Type | Default | Description |
---|---|---|---|
|
string | -- | The name of the default Grafana admin user (who has full permissions). Required |
|
string | -- | Full URL used to access Grafana from a web browser. Required |
|
string | admin | The name of the admin user. |
|
dict | -- | 'alerting' configuration section. Defaults to: true
|
|
dict | -- | 'analytics' configuration section. Defaults to: {}
|
|
dict | -- | 'auth' configuration section. Defaults to: {}
|
|
string | -- | Path to a local directory containing dashboards files in json format. Defaults to 'dashboards'. |
|
list | -- | List of dashboards which should be imported. Example: - dashboard_id: 111 revision_id: 1 datasource: prometheus |
|
string | -- | White list of allowed ips/domains to use in data sources. Format: ip_or_domain:port separated by spaces. |
|
dict | -- | 'database' configuration section. Defaults to: { type: sqlite3 } |
|
list | -- | List of datasources which should be configured. Example: - name: prometheus type: prometheus access: proxy url: 'http://{{ prometheus_web_listen_address }}' basicAuth: false |
|
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. |
|
boolean | -- | Send welcome email after signing up. |
|
dict | -- | Optional Environment param for Grafana installation, usefull ie for setting http_proxy. |
|
dict | -- | 'image_storage' configuration section. Defaults to: {}
|
|
string | -- | The grafana instance name. Defaults to: {{ ansible_fqdn | default(ansible_host) | default(inventory_hostname) }} |
|
dict | -- | 'ldap' configuration section. Defaults to: {}
|
|
string | -- | The address the grafana service listens on. Defaults to: '0.0.0.0' |
|
integer | -- | The port the grafana service listens on. Defaults to 3000. |
|
integer | -- | The number of days the keep me logged in / remember me cookie lasts. |
|
dict | -- | 'metrics' configuration section. Defaults to: {}
|
|
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. |
|
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 } |
|
dict | -- | 'session' configuration section. Defaults to: {}
|
|
dict | -- | 'smtp' configuration section. Defaults to: {}
|
|
dict | -- | 'snapshots' configuration section. Defaults to: {}
|
|
dict | -- | 'tracing' configuration section. Defaults to: {}
|
|
dict | -- | 'users' configuration section. Defaults to: { allow_sign_up: false, auto_assign_org_role: Viewer, default_theme: dark } |
|
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.
Code
doc: short_help: Installs the grafana service. references: cloudalchemy.grafana Ansible role: https://github.com/cloudalchemy/ansible-grafana examples: - title: Install Grafana and add a Prometheus datasource and a matching dashboard. desc: | Check out [the freckles security docs](https://freckles.io/doc/security) if you are concerned about providing the password in plain text. vars: 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 args: version: doc: short_help: The grafana version. help: | The grafana version. Defaults to 'latest'. type: string required: false instance_name: doc: short_help: The grafana instance name. help: | The grafana instance name. Defaults to: {{ ansible_fqdn | default(ansible_host) | default(inventory_hostname) }} required: false type: string listen_address: doc: short_help: The address the service listens on. help: | The address the grafana service listens on. Defaults to: '0.0.0.0' type: string required: false listen_port: doc: short_help: The port the service listens on. help: | The port the grafana service listens on. Defaults to 3000. type: integer required: false listen_url: doc: short_help: The full url to access this grafana instance. help: | Full URL used to access Grafana from a web browser. type: string required: true server_config: doc: short_help: server config help: | ['server' configuration](http://docs.grafana.org/installation/configuration/#server) section. Defaults to: { protocol: http, enforce_domain: false, socket: "", cert_key: "", cert_file: "", enable_gzip: false, static_root_path: public, router_logging: false } references: - "[grafana 'server' configuration documentation](http://docs.grafana.org/installation/configuration/#server)" type: dict required: false empty: true # security_config: # doc: # short_help: security config # help: | # ['security' configuration](http://docs.grafana.org/installation/configuration/#security) section. # # Defaults to: # # { # admin_user: admin, # admin_password: "" # } # references: # - "[grafana 'security' configuration documentation](http://docs.grafana.org/installation/configuration/#security)" # type: dict # required: false # empty: true database_config: doc: short_help: database config help: | ['database' configuration](http://docs.grafana.org/installation/configuration/#database) section. Defaults to: { type: sqlite3 } references: - "[grafana 'database' configuration documentation](http://docs.grafana.org/installation/configuration/#database)" type: dict required: false empty: true auth_config: doc: short_help: auth config help: | ['auth' configuration](http://docs.grafana.org/installation/configuration/#auth) section. Defaults to: {} references: - "[grafana 'auth' configuration documentation](http://docs.grafana.org/installation/configuration/#auth)" type: dict required: false empty: true users_config: doc: short_help: users config help: | ['users' configuration](http://docs.grafana.org/installation/configuration/#users) section. Defaults to: { allow_sign_up: false, auto_assign_org_role: Viewer, default_theme: dark } references: - "[grafana 'users' configuration documentation](http://docs.grafana.org/installation/configuration/#users)" type: dict required: false empty: true ldap_config: doc: short_help: ldap config help: | ['ldap' configuration](http://docs.grafana.org/installation/configuration/#ldap) section. Defaults to: {} references: - "[grafana 'ldap' configuration documentation](http://docs.grafana.org/installation/configuration/#ldap)" type: dict required: false empty: true session_config: doc: short_help: session config help: | ['session' configuration](http://docs.grafana.org/installation/configuration/#session) section. Defaults to: {} references: - "[grafana 'session' configuration documentation](http://docs.grafana.org/installation/configuration/#session)" type: dict required: false empty: true analytics_config: doc: short_help: analytics config help: | ['analytics' configuration](http://docs.grafana.org/installation/configuration/#analytics) section. Defaults to: {} references: - "[grafana 'analytics' configuration documentation](http://docs.grafana.org/installation/configuration/#analytics)" type: dict required: false empty: true smtp_config: doc: short_help: smtp config help: | ['smtp' configuration](http://docs.grafana.org/installation/configuration/#smtp) section. Defaults to: {} references: - "[grafana 'smtp' configuration documentation](http://docs.grafana.org/installation/configuration/#smtp)" type: dict required: false empty: true alerting_config: doc: short_help: alerting config help: | ['alerting' configuration](http://docs.grafana.org/installation/configuration/#alerting) section. Defaults to: true references: - "[grafana 'alerting' configuration documentation](http://docs.grafana.org/installation/configuration/#alerting)" type: dict required: false empty: true metrics_config: doc: short_help: metrics config help: | ['metrics' configuration](http://docs.grafana.org/installation/configuration/#metrics) section. Defaults to: {} references: - "[grafana 'metrics' configuration documentation](http://docs.grafana.org/installation/configuration/#metrics)" type: dict required: false empty: true tracing_config: doc: short_help: tracing config help: | ['tracing' configuration](http://docs.grafana.org/installation/configuration/#tracing) section. Defaults to: {} references: - "[grafana 'tracing' configuration documentation](http://docs.grafana.org/installation/configuration/#tracing)" type: dict required: false empty: true snapshots_config: doc: short_help: snapshots config help: | ['snapshots' configuration](http://docs.grafana.org/installation/configuration/#snapshots) section. Defaults to: {} references: - "[grafana 'snapshots' configuration documentation](http://docs.grafana.org/installation/configuration/#snapshots)" type: dict required: false empty: true image_storage_config: doc: short_help: image_storage config help: | ['image_storage' configuration](http://docs.grafana.org/installation/configuration/#image_storage) section. Defaults to: {} references: - "[grafana 'image_storage' configuration documentation](http://docs.grafana.org/installation/configuration/#image_storage)" type: dict empty: true required: false email_on_sign_up: doc: short_help: Send welcome email after signing up. type: boolean required: false dashboards: doc: short_help: List of dashboards which should be imported. help: | List of dashboards which should be imported. Example: - dashboard_id: 111 revision_id: 1 datasource: prometheus type: list schema: type: dict schema: dashboard_id: type: integer required: true empty: false revision_id: type: integer required: false default: 1 empty: false datasource: type: string required: true empty: false required: false empty: true cli: metavar: DASHBOARD param_decls: - --import-dashboard dashboard_dir: doc: short_help: Path to a local directory containing dashboards files. help: | Path to a local directory containing dashboards files in json format. Defaults to 'dashboards'. type: string required: false empty: false datasources: doc: short_help: List of datasources which should be configured. help: | List of datasources which should be configured. Example: - name: prometheus type: prometheus access: proxy url: 'http://{{ prometheus_web_listen_address }}' basicAuth: false type: list empty: true required: false environment: doc: short_help: Optional Environment parameters for Grafana installation. help: | Optional Environment param for Grafana installation, usefull ie for setting http_proxy. type: dict required: false empty: true admin_user: doc: short_help: The name of the admin user. type: string required: false default: admin admin_password: doc: short_help: The password of the default Grafana admin. help: | The name of the default Grafana admin user (who has full permissions). type: string required: true secret: true login_remember_days: doc: short_help: The number of days the keep me logged in / remember me cookie lasts. type: integer required: false secret_key: doc: short_help: Secret key. help: | 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. type: string required: false secret: true disable_gravatar: doc: short_help: Whether to disable gravatar for user profile images. help: | Whether to disable gravatar for user profile images. Set to true to disable the use of Gravatar for user profile images. Default is false. type: boolean required: false data_source_proxy_whitelist: doc: short_help: White list of allowed ips/domains to use in data sources. help: | White list of allowed ips/domains to use in data sources. Format: ip_or_domain:port separated by spaces. type: string required: false empty: false frecklets: - path-is-absent: path: /tmp/dashboards become: true - task: become: true frecklet: name: cloudalchemy.grafana type: ansible-role resources: ansible-role: - cloudalchemy.grafana desc: msg: installing grafana references: "'cloudalchemy.grafana' Ansible role": https://github.com/cloudalchemy/ansible-grafana properties: idempotent: true internet: true elevated: true vars: grafana_version: '{{:: version ::}}' grafana_instance: '{{:: instance_name ::}}' grafana_address: '{{:: listen_address ::}}' grafana_port: '{{:: listen_port ::}}' grafana_url: '{{:: listen_url ::}}' grafana_server: '{{:: server_config ::}}' grafana_security: admin_user: '{{:: admin_user ::}}' admin_password: '{{:: admin_password ::}}' login_remember_days: '{{:: login_remember_days ::}}' secret_key: '{{:: secret_key ::}}' disable_gravatar: '{{:: disable_gravatar ::}}' data_source_proxy_whitelist: '{{:: data_source_proxy_whitelist ::}}' grafana_database: '{{:: database_config ::}}' grafana_users: '{{:: users_config ::}}' grafana_auth: '{{:: auth_config ::}}' grafana_ldap: '{{:: ldap_config ::}}' grafana_session: '{{:: session_config ::}}' grafana_analytics: '{{:: analytics_config ::}}' grafana_smtp: '{{:: smtp_config ::}}' grafana_alerting: '{{:: alerting_config ::}}' grafana_metrics: '{{:: metrics_config ::}}' grafana_tracing: '{{:: tracing_config ::}}' grafana_snapshots: '{{:: snapshots_config ::}}' grafana_image_storage: '{{:: image_storage_config ::}}' grafana_welcome_email_on_sign_up: '{{:: email_on_sign_up ::}}' grafana_dashboards: '{{:: dashboards ::}}' grafana_dashboard_dir: '{{:: dashboard_dir ::}}' grafana_datasources: '{{:: datasources ::}}' grafana_environment: '{{:: environment ::}}'
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. --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.
# -*- coding: utf-8 -*- # # module path: pycklets.grafana_service.GrafanaService # from dataclasses import dataclass from pyckles import AutoPycklet from typing import * # noqa @dataclass class GrafanaService(AutoPycklet): """Installs the grafana service. Args: admin_password: The password of the default Grafana admin. admin_user: The name of the admin user. alerting_config: alerting config analytics_config: analytics config auth_config: auth config dashboard_dir: Path to a local directory containing dashboards files. dashboards: List of dashboards which should be imported. data_source_proxy_whitelist: White list of allowed ips/domains to use in data sources. database_config: database config datasources: List of datasources which should be configured. disable_gravatar: Whether to disable gravatar for user profile images. email_on_sign_up: Send welcome email after signing up. environment: Optional Environment parameters for Grafana installation. image_storage_config: image_storage config instance_name: The grafana instance name. ldap_config: ldap config listen_address: The address the service listens on. listen_port: The port the service listens on. listen_url: The full url to access this grafana instance. login_remember_days: The number of days the keep me logged in / remember me cookie lasts. metrics_config: metrics config secret_key: Secret key. server_config: server config session_config: session config smtp_config: smtp config snapshots_config: snapshots config tracing_config: tracing config users_config: users config version: The grafana version. """ FRECKLET_ID = "grafana-service" admin_password: str = None admin_user: str = None alerting_config: Dict = None analytics_config: Dict = None auth_config: Dict = None dashboard_dir: str = None dashboards: List = None data_source_proxy_whitelist: str = None database_config: Dict = None datasources: List = None disable_gravatar: bool = None email_on_sign_up: bool = None environment: Dict = None image_storage_config: Dict = None instance_name: str = None ldap_config: Dict = None listen_address: str = None listen_port: int = None listen_url: str = None login_remember_days: int = None metrics_config: Dict = None secret_key: str = None server_config: Dict = None session_config: Dict = None smtp_config: Dict = None snapshots_config: Dict = None tracing_config: Dict = None users_config: Dict = None version: str = None def __post_init__(self): super(GrafanaService, self).__init__(var_names=["admin_password", "admin_user", "alerting_config", "analytics_config", "auth_config", "dashboard_dir", "dashboards", "data_source_proxy_whitelist", "database_config", "datasources", "disable_gravatar", "email_on_sign_up", "environment", "image_storage_config", "instance_name", "ldap_config", "listen_address", "listen_port", "listen_url", "login_remember_days", "metrics_config", "secret_key", "server_config", "session_config", "smtp_config", "snapshots_config", "tracing_config", "users_config", "version"]) frecklet_class = GrafanaService
# -*- coding: utf-8 -*- # # module path: pycklets.grafana_service.GrafanaService # from pyckles import AutoPycklet class GrafanaService(AutoPycklet): """Installs the grafana service. Args: admin_password: The password of the default Grafana admin. admin_user: The name of the admin user. alerting_config: alerting config analytics_config: analytics config auth_config: auth config dashboard_dir: Path to a local directory containing dashboards files. dashboards: List of dashboards which should be imported. data_source_proxy_whitelist: White list of allowed ips/domains to use in data sources. database_config: database config datasources: List of datasources which should be configured. disable_gravatar: Whether to disable gravatar for user profile images. email_on_sign_up: Send welcome email after signing up. environment: Optional Environment parameters for Grafana installation. image_storage_config: image_storage config instance_name: The grafana instance name. ldap_config: ldap config listen_address: The address the service listens on. listen_port: The port the service listens on. listen_url: The full url to access this grafana instance. login_remember_days: The number of days the keep me logged in / remember me cookie lasts. metrics_config: metrics config secret_key: Secret key. server_config: server config session_config: session config smtp_config: smtp config snapshots_config: snapshots config tracing_config: tracing config users_config: users config version: The grafana version. """ FRECKLET_ID = "grafana-service" def __init__(self, admin_password=None, admin_user="admin", alerting_config=None, analytics_config=None, auth_config=None, dashboard_dir=None, dashboards=None, data_source_proxy_whitelist=None, database_config=None, datasources=None, disable_gravatar=None, email_on_sign_up=None, environment=None, image_storage_config=None, instance_name=None, ldap_config=None, listen_address=None, listen_port=None, listen_url=None, login_remember_days=None, metrics_config=None, secret_key=None, server_config=None, session_config=None, smtp_config=None, snapshots_config=None, tracing_config=None, users_config=None, version=None): super(GrafanaService, self).__init__(var_names=["admin_password", "admin_user", "alerting_config", "analytics_config", "auth_config", "dashboard_dir", "dashboards", "data_source_proxy_whitelist", "database_config", "datasources", "disable_gravatar", "email_on_sign_up", "environment", "image_storage_config", "instance_name", "ldap_config", "listen_address", "listen_port", "listen_url", "login_remember_days", "metrics_config", "secret_key", "server_config", "session_config", "smtp_config", "snapshots_config", "tracing_config", "users_config", "version"]) self._admin_password = admin_password self._admin_user = admin_user self._alerting_config = alerting_config self._analytics_config = analytics_config self._auth_config = auth_config self._dashboard_dir = dashboard_dir self._dashboards = dashboards self._data_source_proxy_whitelist = data_source_proxy_whitelist self._database_config = database_config self._datasources = datasources self._disable_gravatar = disable_gravatar self._email_on_sign_up = email_on_sign_up self._environment = environment self._image_storage_config = image_storage_config self._instance_name = instance_name self._ldap_config = ldap_config self._listen_address = listen_address self._listen_port = listen_port self._listen_url = listen_url self._login_remember_days = login_remember_days self._metrics_config = metrics_config self._secret_key = secret_key self._server_config = server_config self._session_config = session_config self._smtp_config = smtp_config self._snapshots_config = snapshots_config self._tracing_config = tracing_config self._users_config = users_config self._version = version @property def admin_password(self): return self._admin_password @admin_password.setter def admin_password(self, admin_password): self._admin_password = admin_password @property def admin_user(self): return self._admin_user @admin_user.setter def admin_user(self, admin_user): self._admin_user = admin_user @property def alerting_config(self): return self._alerting_config @alerting_config.setter def alerting_config(self, alerting_config): self._alerting_config = alerting_config @property def analytics_config(self): return self._analytics_config @analytics_config.setter def analytics_config(self, analytics_config): self._analytics_config = analytics_config @property def auth_config(self): return self._auth_config @auth_config.setter def auth_config(self, auth_config): self._auth_config = auth_config @property def dashboard_dir(self): return self._dashboard_dir @dashboard_dir.setter def dashboard_dir(self, dashboard_dir): self._dashboard_dir = dashboard_dir @property def dashboards(self): return self._dashboards @dashboards.setter def dashboards(self, dashboards): self._dashboards = dashboards @property def data_source_proxy_whitelist(self): return self._data_source_proxy_whitelist @data_source_proxy_whitelist.setter def data_source_proxy_whitelist(self, data_source_proxy_whitelist): self._data_source_proxy_whitelist = data_source_proxy_whitelist @property def database_config(self): return self._database_config @database_config.setter def database_config(self, database_config): self._database_config = database_config @property def datasources(self): return self._datasources @datasources.setter def datasources(self, datasources): self._datasources = datasources @property def disable_gravatar(self): return self._disable_gravatar @disable_gravatar.setter def disable_gravatar(self, disable_gravatar): self._disable_gravatar = disable_gravatar @property def email_on_sign_up(self): return self._email_on_sign_up @email_on_sign_up.setter def email_on_sign_up(self, email_on_sign_up): self._email_on_sign_up = email_on_sign_up @property def environment(self): return self._environment @environment.setter def environment(self, environment): self._environment = environment @property def image_storage_config(self): return self._image_storage_config @image_storage_config.setter def image_storage_config(self, image_storage_config): self._image_storage_config = image_storage_config @property def instance_name(self): return self._instance_name @instance_name.setter def instance_name(self, instance_name): self._instance_name = instance_name @property def ldap_config(self): return self._ldap_config @ldap_config.setter def ldap_config(self, ldap_config): self._ldap_config = ldap_config @property def listen_address(self): return self._listen_address @listen_address.setter def listen_address(self, listen_address): self._listen_address = listen_address @property def listen_port(self): return self._listen_port @listen_port.setter def listen_port(self, listen_port): self._listen_port = listen_port @property def listen_url(self): return self._listen_url @listen_url.setter def listen_url(self, listen_url): self._listen_url = listen_url @property def login_remember_days(self): return self._login_remember_days @login_remember_days.setter def login_remember_days(self, login_remember_days): self._login_remember_days = login_remember_days @property def metrics_config(self): return self._metrics_config @metrics_config.setter def metrics_config(self, metrics_config): self._metrics_config = metrics_config @property def secret_key(self): return self._secret_key @secret_key.setter def secret_key(self, secret_key): self._secret_key = secret_key @property def server_config(self): return self._server_config @server_config.setter def server_config(self, server_config): self._server_config = server_config @property def session_config(self): return self._session_config @session_config.setter def session_config(self, session_config): self._session_config = session_config @property def smtp_config(self): return self._smtp_config @smtp_config.setter def smtp_config(self, smtp_config): self._smtp_config = smtp_config @property def snapshots_config(self): return self._snapshots_config @snapshots_config.setter def snapshots_config(self, snapshots_config): self._snapshots_config = snapshots_config @property def tracing_config(self): return self._tracing_config @tracing_config.setter def tracing_config(self, tracing_config): self._tracing_config = tracing_config @property def users_config(self): return self._users_config @users_config.setter def users_config(self, users_config): self._users_config = users_config @property def version(self): return self._version @version.setter def version(self, version): self._version = version frecklet_class = GrafanaService