{"id":15022793,"url":"https://github.com/voxpupuli/puppet-grafana","last_synced_at":"2025-12-11T21:46:32.638Z","repository":{"id":37579862,"uuid":"75810834","full_name":"voxpupuli/puppet-grafana","owner":"voxpupuli","description":"Puppet module to manage Grafana","archived":false,"fork":true,"pushed_at":"2024-10-07T23:46:43.000Z","size":1044,"stargazers_count":15,"open_issues_count":41,"forks_count":107,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-10-29T14:22:35.977Z","etag":null,"topics":["bsd-puppet-module","centos-puppet-module","debian-puppet-module","freebsd-puppet-module","hacktoberfest","linux-puppet-module","puppet","redhat-puppet-module","sles-puppet-module","ubuntu-puppet-module"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"bfraser/puppet-grafana","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/voxpupuli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"open_collective":"vox-pupuli","github":"voxpupuli"}},"created_at":"2016-12-07T07:26:42.000Z","updated_at":"2024-10-07T23:46:47.000Z","dependencies_parsed_at":"2023-09-24T10:28:53.617Z","dependency_job_id":null,"html_url":"https://github.com/voxpupuli/puppet-grafana","commit_stats":{"total_commits":534,"total_committers":88,"mean_commits":6.068181818181818,"dds":0.7415730337078652,"last_synced_commit":"5967d98d5be50560d4879004148838c6923de650"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpupuli%2Fpuppet-grafana","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpupuli%2Fpuppet-grafana/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpupuli%2Fpuppet-grafana/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpupuli%2Fpuppet-grafana/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voxpupuli","download_url":"https://codeload.github.com/voxpupuli/puppet-grafana/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234712828,"owners_count":18875519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bsd-puppet-module","centos-puppet-module","debian-puppet-module","freebsd-puppet-module","hacktoberfest","linux-puppet-module","puppet","redhat-puppet-module","sles-puppet-module","ubuntu-puppet-module"],"created_at":"2024-09-24T19:58:23.335Z","updated_at":"2025-09-30T07:30:36.912Z","avatar_url":"https://github.com/voxpupuli.png","language":"Ruby","funding_links":["https://opencollective.com/vox-pupuli","https://github.com/sponsors/voxpupuli"],"categories":[],"sub_categories":[],"readme":"# grafana\n\n[![Build Status](https://github.com/voxpupuli/puppet-grafana/workflows/CI/badge.svg)](https://github.com/voxpupuli/puppet-grafana/actions?query=workflow%3ACI)\n[![Release](https://github.com/voxpupuli/puppet-grafana/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/puppet-grafana/actions/workflows/release.yml)\n[![Puppet Forge](https://img.shields.io/puppetforge/v/puppet/grafana.svg)](https://forge.puppetlabs.com/puppet/grafana)\n[![Puppet Forge - downloads](https://img.shields.io/puppetforge/dt/puppet/grafana.svg)](https://forge.puppetlabs.com/puppet/grafana)\n[![Puppet Forge - endorsement](https://img.shields.io/puppetforge/e/puppet/grafana.svg)](https://forge.puppetlabs.com/puppet/grafana)\n[![Puppet Forge - scores](https://img.shields.io/puppetforge/f/puppet/grafana.svg)](https://forge.puppetlabs.com/puppet/grafana)\n[![puppetmodule.info docs](http://www.puppetmodule.info/images/badge.png)](http://www.puppetmodule.info/m/puppet-grafana)\n[![Apache-2 License](https://img.shields.io/github/license/voxpupuli/puppet-grafana.svg)](LICENSE)\n\n#### Table of Contents\n\n- [Overview](#overview)\n- [Module Description](#module-description)\n- [Setup](#setup)\n  - [Requirements](#requirements)\n  - [Beginning with Grafana](#beginning-with-grafana)\n- [Usage](#usage)\n  - [Classes and Defined Types](#classes-and-defined-types)\n  - [Advanced usage](#advanced-usage)\n- [Tasks](#tasks)\n  - [`change_grafana_admin_password`](#change_grafana_admin_password)\n- [Limitations](#limitations)\n- [Development](#development)\n  - [Authors](#authors)\n- [Copyright and License](#copyright-and-license)\n\n## Overview\n\nThis module installs Grafana, a dashboard and graph editor for Graphite,\nInfluxDB and OpenTSDB.\n\n## Module Description\n\nWith the 9.0.0 release of this module we only support Grafana 6.x/7.x/8.x.\nVersion 8 of the module was tested successfully on Grafana 6 and 7.\n\n## Setup\n\nThis module will:\n\n* Install Grafana using your preferred method: package (default), Docker\n  container, or tar archive\n* Allow you to override the version of Grafana to be installed, and / or the\n  package source\n* Perform basic configuration of Grafana\n\n### Requirements\n\n* If using an operating system of the Debian-based family, and the \"repo\"\n`install_method`, you will need to ensure that\n[puppetlabs-apt](https://forge.puppet.com/puppetlabs/apt) version 4.x is\ninstalled.\n* If using Docker, you will need the\n[garethr/docker](https://forge.puppet.com/garethr/docker) module version 5.x\n\n### Beginning with Grafana\n\nTo install Grafana with the default parameters:\n\n```puppet\n    class { 'grafana': }\n```\n\nThis assumes that you want to install Grafana using the 'package' method. To\nestablish customized parameters:\n\n```puppet\n    class { 'grafana':\n      install_method  =\u003e 'docker',\n    }\n```\n\n## Usage\n\n### Classes and Defined Types\n\n#### Class: `grafana`\n\nThe Grafana module's primary class, `grafana`, guides the basic setup of Grafana\non your system.\n\n```puppet\n    class { 'grafana': }\n```\n\n**Parameters within `grafana`:**\n\n##### `archive_source`\n\nThe download location of a tarball to use with the 'archive' install method.\nDefaults to the URL of the latest version of Grafana available at the time of\nmodule release.\n\n##### `cfg_location`\n\nConfigures the location to which the Grafana configuration is written. The\ndefault location is '/etc/grafana/grafana.ini'.\n\n##### `cfg`\n\nManages the Grafana configuration file. Grafana comes with its own default\nsettings in a different configuration file (/opt/grafana/current/conf/defaults.ini),\ntherefore this module does not supply any defaults.\n\nThis parameter only accepts a `Hash` (or `Sensitive[Hash]`) as its value. Keys with hashes as values will\ngenerate sections, any other values are just plain values. The example below will\nresult in...\n\n```puppet\n    class { 'grafana':\n      cfg =\u003e {\n        app_mode =\u003e 'production',\n        server   =\u003e {\n          http_port     =\u003e 8080,\n        },\n        database =\u003e {\n          type          =\u003e 'mysql',\n          host          =\u003e '127.0.0.1:3306',\n          name          =\u003e 'grafana',\n          user          =\u003e 'root',\n          password      =\u003e '',\n        },\n        users    =\u003e {\n          allow_sign_up =\u003e false,\n        },\n      },\n    }\n```\n\n...the following Grafana configuration:\n\n```ini\n# This file is managed by Puppet, any changes will be overwritten\n\napp_mode = production\n\n[server]\nhttp_port = 8080\n\n[database]\ntype = mysql\nhost = 127.0.0.1:3306\nname = grafana\nuser = root\npassword =\n\n[users]\nallow_sign_up = false\n```\n\nSome minor notes:\n\n* If you want empty values, just use an empty string.\n* Keys that contains dots (like auth.google) need to be quoted.\n* The order of the keys in this hash is the same as they will be written to the\n  configuration file. So settings that do not fall under a section will have to\n  come before any sections in the hash.\n* If your configuration contains secrets you want hidden in Puppet log output and reports\n  use a `Sensitive[Hash]` instead of a normal `Hash`\n\n#### `ldap_cfg`\n\nManages the Grafana LDAP configuration file. This hash is directly translated\ninto the corresponding TOML file, allowing for full flexibility in generating\nthe configuration.\n\nSee the [LDAP documentation](https://grafana.com/docs/grafana/latest/setup-grafana/configure-security/configure-authentication/ldap/)\nfor more information.\n\n##### TOML note\n\nThis option **requires** the [toml](https://rubygems.org/gems/toml/) gem.\n\n```sh\npuppet resource package toml ensure=installed provider=puppetserver_gem\n```\n\n```puppet\npackage { 'toml':\n  provider =\u003e puppetserver_gem,\n}\n```\n\nThis enables the puppetserver to compile a catalog.\nIf you've the [generate types](https://www.puppet.com/docs/puppet/latest/environment_isolation.html) option enabled in r10k or code-manager, you also need to install the gem for the puppet-agent Ruby:\n\n```sh\npuppet resource package toml ensure=installed provider=puppet_gem\n```\n\n```puppet\npackage { 'toml-puppetserver':\n  name     =\u003e 'toml',\n  provider =\u003e puppetserver_gem,\n}\n\npackage { 'toml-puppet':\n  name     =\u003e 'toml',\n  provider =\u003e puppet_gem,\n}\n```\n\nAfter installing the gem(s), restart the Puppet Server and if using r10k or code-manager, re-deploy the environment(s).\n\n```sh\nsystemctl restart puppetserver.service\nr10k deploy environment --generate-types\n```\n\n##### secrets\n\nLDAP configuration usually contains secrets. If you want to stop these being leaked in logs and reports,\nthe `ldap_cfg` parameter will optionally accept the `Sensitive` data type.\n\n##### cfg note\n\nThis option by itself is not sufficient to enable LDAP configuration as it must\nbe enabled in the main configuration file. Enable it in cfg with:\n\n```\n'auth.ldap' =\u003e {\n  enabled     =\u003e 'true',\n  config_file =\u003e '/etc/grafana/ldap.toml',\n},\n```\n#### Example LDAP config\n\n```\nldap_cfg =\u003e Sensitive({\n  servers =\u003e [\n    { host            =\u003e 'ldapserver1.domain1.com',\n      port            =\u003e 636,\n      use_ssl         =\u003e true,\n      search_filter   =\u003e '(sAMAccountName=%s)',\n      search_base_dns =\u003e [ 'dc=domain1,dc=com' ],\n      bind_dn         =\u003e 'user@domain1.com',\n      bind_password   =\u003e 'passwordhere',\n    },\n  ],\n  'servers.attributes' =\u003e {\n    name      =\u003e 'givenName',\n    surname   =\u003e 'sn',\n    username  =\u003e 'sAMAccountName',\n    member_of =\u003e 'memberOf',\n    email     =\u003e 'mail',\n  }\n}),\n```\n\nIf you want to connect to multiple LDAP servers using different configurations,\nuse an array to enwrap the configurations as shown below.\n\n```\nldap_cfg =\u003e Sensitive([\n  {\n    servers =\u003e [\n      {\n        host            =\u003e 'ldapserver1.domain1.com',\n        port            =\u003e 636,\n        use_ssl         =\u003e true,\n        search_filter   =\u003e '(sAMAccountName=%s)',\n        search_base_dns =\u003e [ 'dc=domain1,dc=com' ],\n        bind_dn         =\u003e 'user@domain1.com',\n        bind_password   =\u003e 'passwordhere',\n      },\n    ],\n    'servers.attributes' =\u003e {\n      name      =\u003e 'givenName',\n      surname   =\u003e 'sn',\n      username  =\u003e 'sAMAccountName',\n      member_of =\u003e 'memberOf',\n      email     =\u003e 'mail',\n    },\n    'servers.group_mappings' =\u003e [\n      {\n        group_dn =\u003e 'cn=grafana_viewers,ou=groups,dc=domain1,dc=com',\n        org_role =\u003e 'Viewer',\n      }\n    ],\n  },\n  {\n    servers =\u003e [\n      {\n        host            =\u003e 'ldapserver2.domain2.com',\n        port            =\u003e 389,\n        use_ssl         =\u003e false,\n        start_tls       =\u003e true,\n        search_filter   =\u003e '(uid=%s)',\n        search_base_dns =\u003e [ 'dc=domain2,dc=com' ],\n        bind_dn         =\u003e 'user@domain2.com',\n        bind_password   =\u003e 'passwordhere',\n      },\n    ],\n    'servers.attributes' =\u003e {\n      name      =\u003e 'givenName',\n      surname   =\u003e 'sn',\n      username  =\u003e 'uid',\n      member_of =\u003e 'memberOf',\n      email     =\u003e 'mail',\n    }\n    'servers.group_mappings' =\u003e [\n      {\n        'group_dn'      =\u003e 'cn=grafana_admins,ou=groups,dc=domain2,dc=com',\n        'org_role'      =\u003e 'Admin',\n        'grafana_admin' =\u003e true,\n      }\n    ],\n  },\n])\n\n\n#####\n# or in hiera-yaml style\ngrafana::ldap_cfg:\n  - servers:\n      - host: ldapserver1.domain1.com\n        port: 636\n        use_ssl: true\n        search_filter: '(sAMAccountName=%s)'\n        search_base_dns: ['dc=domain1,dc=com']\n        bind_dn: 'user@domain1.com'\n        bind_password: 'passwordhere'\n    servers.attributes:\n      name: givenName\n      surname: sn\n      username: sAMAccountName\n      member_of: memberOf\n      email: mail\n    servers.group_mappings:\n      - group_dn: cn=grafana_viewers,ou=groups,dc=domain1,dc=com\n        org_role: Viewer\n\n  - servers:\n      - host: ldapserver2.domain2.com\n        port: 389\n        use_ssl: false\n        start_tls: true\n        search_filter: '(uid=%s)',\n        search_base_dns: ['dc=domain2,dc=com']\n        bind_dn: 'user@domain2.com'\n        bind_password: 'passwordhere'\n    servers.attributes:\n      name: givenName\n      surname: sn\n      username: uid\n      member_of: memberOf\n      email: mail\n    servers.group_mappings:\n      - group_dn: cn=grafana_admins,ou=groups,dc=domain2,dc=com\n        org_role: Admin\n        grafana_admin: true\n\n\n#####\n```\n\n##### `container_cfg`\n\nBoolean to control whether a configuration file should be generated when using\nthe 'docker' install method. If 'true', use the 'cfg' and 'cfg_location'\nparameters to control creation of the file. Defaults to false.\n\n##### `container_params`\n\nA hash of parameters to use when creating the Docker container. For use with the\n'docker' install method. Refer to documentation of the 'docker::run' resource in\nthe [garethr-docker](https://github.com/garethr/garethr-docker) module for details\nof available parameters. Defaults to:\n\n```puppet\ncontainer_params =\u003e {\n  'image' =\u003e 'grafana/grafana:latest',\n  'ports' =\u003e '3000:3000'\n}\n```\n\n##### `data_dir`\n\nThe directory Grafana will use for storing its data. Defaults to '/var/lib/grafana'.\n\n##### `install_dir`\n\nThe installation directory to be used with the 'archive' install method. Defaults\nto '/usr/share/grafana'.\n\n##### `install_method`\n\nControls which method to use for installing Grafana. Valid options are: 'archive',\n'docker', 'repo' and 'package'. The default is 'package'. If you wish to use the\n'docker' installation method, you will need to include the 'docker' class in your\nnode's manifest / profile. If you wish to use the 'repo' installation method, you\ncan control whether the official Grafana repositories will be used. See\n`manage_package_repo` below for details.\n\n##### `manage_package_repo`\n\nBoolean. When using the 'repo' installation method, controls whether the official\nGrafana repositories are enabled on your host. If true, the official Grafana\nrepositories will be enabled. If false, the module assumes you are managing your\nown package repository and will not set one up for you. Defaults to true.\n\n##### `plugins`\n\nHash. This is a passthrough to call `create_resources()` on the\n`grafana_plugin` resource type.\n\n##### `package_name`\n\nThe name of the package managed with the 'package' install method. Defaults to\n'grafana'.\n\n##### `package_source`\n\nThe download location of a package to be used with the 'package' install method.\nDefaults to the URL of the latest version of Grafana available at the time of\nmodule release.\n\n##### `provisioning_datasources`\n\nA Hash which is converted to YAML for grafana to provision data\nsources. See [provisioning\ngrafana](http://docs.grafana.org/administration/provisioning/) for\ndetails and example config file. Requires grafana \u003e v5.0.0.\n\nThis is very useful with Hiera as you can provide a yaml\nhash/dictionary which will effectively 'passthrough' to grafana. See\n**Advanced Usage** for examples.\n\n##### `provisioning_dashboards`\n\nA Hash which is converted to YAML for grafana to provision\ndashboards. See [provisioning\ngrafana](http://docs.grafana.org/administration/provisioning/) for\ndetails and example config file.  Requires grafana \u003e v5.0.0.\n\nThis is very useful with Hiera as you can provide a yaml\nhash/dictionary which will effectively 'passthrough' to grafana. See\n**Advanced Usage** for examples.\n\nN.B. A option named `puppetsource` may be given in the `options` hash\nwhich is not part of grafana's syntax. This option will be extracted\nfrom the hash, and used to \"source\" a directory of dashboards. See\n**Advanced Usage** for details.\n\n#### `provisioning_dashboards_file`\n\nA String that is used as the target file name for the dashabords\nprovisioning file. This way the module can be used to generate placeholder\nfiles so password can be sepecified in a different iteration, avoiding them\nto be put in the module code.\n\n#### `provisioning_datasources_file`\n\nA String that is used as the target file name for the datasources\nprovisioning file. This way the module can be used to generate placeholder\nfiles so password can be sepecified in a different iteration, avoiding them\nto be put in the module code.\n\n##### `rpm_iteration`\n\nUsed when installing Grafana from package ('package' or 'repo' install methods)\non Red Hat based systems. Defaults to '1'. It should not be necessary to change\nthis in most cases.\n\n##### `service_name`\n\nThe name of the service managed with the 'archive' and 'package' install methods.\nDefaults to 'grafana-server'.\n\n##### `version`\n\nThe version of Grafana to install and manage. Defaults to 'installed'\n\n##### `sysconfig_location`\n\nThe RPM and DEB packages bring with them the default environment files for the\nservices. The default location of this file for Debian is /etc/default/grafana-server\nand for RedHat /etc/sysconfig/grafana-server.\n\n##### `sysconfig`\n\nA hash of environment variables for the service. This only has an effect for installations\nwith RPM and DEB packages (if install_method is set to 'package' or 'repo').\n\nExample:\n\n```puppet\nsysconfig =\u003e {\n  'http_proxy' =\u003e 'http://proxy.example.com',\n}\n```\n\n### Advanced usage\n\nThe archive install method will create the user and a \"command line\" service by\ndefault. There are no extra parameters to manage user/service for archive.\nHowever, both check to see if they are defined before defining. This way you can\ncreate your own user and service with your own specifications. (sort of overriding)\nThe service can be a bit tricky, in this example below, the class\nsensu_install::grafana::service creates a startup script and a service{'grafana-server':}\n\nExample:\n\n```puppet\n    user { 'grafana':\n      ensure =\u003e present,\n      uid    =\u003e '1234',\n    }\n    -\u003e\n    class { 'grafana':\n      install_method  =\u003e 'archive',\n    }\n\n    include sensu_install::grafana::service\n\n    # run your service after install/config but before grafana::service\n    Class[::grafana::install]\n    -\u003e\n    Class[sensu_install::grafana::service]\n    -\u003e\n    Class[::grafana::service]\n\n```\n\n\n#### Using a sub-path for Grafana API\n\nIf you are using a sub-path for the Grafana API, you will need to set the `grafana_api_path` parameter for the following custom types:\n- `grafana_dashboard`\n- `grafana_datasource`\n- `grafana_organization`\n- `grafana_user`\n- `grafana_folder`\n- `grafana_team`\n- `grafana_membership`\n- `grafana_dashboard_permission`\n\nFor instance, if your sub-path is `/grafana`, the `grafana_api_path` must\nbe set to `/grafana/api`. Do not add a trailing `/` (slash) at the end of the value.\n\nIf you are not using sub-paths, you do not need to set this parameter.\n\n#### Custom Types and Providers\n\nThe module includes several custom types:\n\n#### `grafana_organization`\n\nIn order to use the organization resource, add the following to your manifest:\n\n```puppet\ngrafana_organization { 'example_org':\n  ensure           =\u003e present,\n  grafana_url      =\u003e 'http://localhost:3000',\n  grafana_user     =\u003e 'admin',\n  grafana_password =\u003e '5ecretPassw0rd',\n}\n```\n\n`grafana_url`, `grafana_user`, and `grafana_password` are required to create organizations via the API.\n\nset `ensure =\u003e absent` if you want to remove an organization.\nRemoving the default organization, (`Main org.`), is not supported.\n\n#### `grafana_team`\n\nIn order to use the team resource, add the following to your manifest:\n\n```puppet\ngrafana_team { 'example_team':\n  ensure           =\u003e 'present',\n  grafana_url      =\u003e 'http://localhost:3000',\n  grafana_user     =\u003e 'admin',\n  grafana_password =\u003e '5ecretPassw0rd',\n  home_dashboard   =\u003e 'example_dashboard',\n  organization     =\u003e 'example_org',\n}\n```\n\nOrganziation must exist if specified.\n\n`grafana_url`, `grafana_user`, and `grafana_password` are required to create teams via the API.\n\n`ensure` is required. If the resource should be `present` or `absent`\n\n`name` is optional if the name will differ from example_team above.\n\n`home_dashboard_folder` is optional. Sets the folder where home dashboard resides. Dashboard folder must exist.\n\n`home_dashboard` is optional. Sets the home dashboard for team. Dashboard must exist.\n\n`organization` is optional. Defaults to `Main org.`\n\n#### `grafana_dashboard_permission`\n\nIn order to use the dashboard permission resource, add one the following to your manifest:\n\nadd permissions for user:\n\n```puppet\ngrafana_dashboard_permission { 'example_user_permission':\n  ensure           =\u003e 'present',\n  grafana_url      =\u003e 'http://localhost:3000',\n  grafana_user     =\u003e 'admin',\n  grafana_password =\u003e '5ecretPassw0rd',\n  dashboard        =\u003e 'example_dashboard',\n  user             =\u003e 'example_user',\n  organization     =\u003e 'example_org',\n}\n```\n\nadd permissions for team:\n\n```puppet\ngrafana_dashboard_permission { 'example_team_permission':\n  ensure           =\u003e 'present',\n  grafana_url      =\u003e 'http://localhost:3000',\n  grafana_user     =\u003e 'admin',\n  grafana_password =\u003e '5ecretPassw0rd',\n  dashboard        =\u003e 'example_dashboard',\n  team             =\u003e 'example_team',\n  organization     =\u003e 'example_org',\n}\n```\n\nOrganziation, team, user and dashboard must exist if specified.\n\n`grafana_url`, `grafana_user`, and `grafana_password` are required to create teams via the API.\n\n`ensure` is required. If the resource should be `present` or `absent`\n\n`dashboard` is required. The dashboard to set permissions for.\n\n`user` is required if `team` not set. The user to add permissions for.\n\n`team` is required if `user` not set. the team to add permissions for.\n\n`name` is optional if the name will differ from example_team above.\n\n`organization` is optional. Defaults to `Main org.`\n\n#### `grafana_membership`\n\nIn order to use the membership resource, add the following to your manifest:\n\n```puppet\ngrafana_membership { 'example_membership':\n  ensure           =\u003e 'present',\n  grafana_url      =\u003e 'http://localhost:3000',\n  grafana_user     =\u003e 'admin',\n  grafana_password =\u003e '5ecretPassw0rd',\n  membership_type  =\u003e 'team',\n  organization     =\u003e 'example_org',\n  target_name      =\u003e 'example_team',\n  user_name        =\u003e 'example_user',\n  role             =\u003e 'Viewer'\n  }\n}\n```\nA membership is the concept of a user belonging to a target - either a `team` or an `organization`\n\nThe user and target must both exist for a membership to be created\n\n`grafana_url`, `grafana_user`, and `grafana_password` are required to create memberships via the API.\n\n`ensure` is required. If the resource should be `present` or `absent`\n\n`membership_type` is required. Either `team` or `organization`\n\n`target_name` is required. Specifies the target of the membership.\n\n`user_name` is required. Specifies the user that is the focus of the membership.\n\n`role` is required. Specifies what rights to grant the user. Either `Viewer`, `Editor` or `Admin`\n\n`organization` is optional when using the `membership_type` of `team`. Defaults to `Main org.`\n\n#### `grafana_dashboard`\n\nIn order to use the dashboard resource, add the following to your manifest:\n\n```puppet\ngrafana_dashboard { 'example_dashboard':\n  grafana_url       =\u003e 'http://localhost:3000',\n  grafana_user      =\u003e 'admin',\n  grafana_password  =\u003e '5ecretPassw0rd',\n  grafana_api_path  =\u003e '/grafana/api',\n  folder            =\u003e 'folder-name',\n  organization      =\u003e 'NewOrg',\n  content           =\u003e template('path/to/exported/file.json'),\n}\n```\n\n`content` must be valid JSON, and is parsed before imported. You can use the JSON generated with the share/export functionality or from the API call to /dashboards/uid but must remove the fields \"id\", \"uid\", \"title\" and \"version\" to make the resource call idempotent.\n`grafana_user` and `grafana_password` are optional, and required when\nauthentication is enabled in Grafana. `grafana_api_path` is optional, and only used when using sub-paths for the API. `organization` is optional, and used when creating a dashboard for a specific organization.\n`folder` is an optional parameter, but the folder resource must exist.\n\nExample:\nMake sure the `grafana-server` service is up and running before creating the `grafana_dashboard` definition. One option is to use the `http_conn_validator` from the [healthcheck](https://forge.puppet.com/puppet/healthcheck) module\n\n```puppet\nhttp_conn_validator { 'grafana-conn-validator' :\n  host     =\u003e 'localhost',\n  port     =\u003e '3000',\n  use_ssl  =\u003e false,\n  test_url =\u003e '/public/img/grafana_icon.svg',\n  require  =\u003e Class['grafana'],\n}\n-\u003e grafana_dashboard { 'example_dashboard':\n  grafana_url       =\u003e 'http://localhost:3000',\n  grafana_user      =\u003e 'admin',\n  grafana_password  =\u003e '5ecretPassw0rd',\n  content           =\u003e template('path/to/exported/file.json'),\n}\n```\n\n##### `grafana_datasource`\n\nIn order to use the datasource resource, add the following to your manifest:\n\n```puppet\ngrafana_datasource { 'influxdb':\n  grafana_url      =\u003e 'http://localhost:3000',\n  grafana_user     =\u003e 'admin',\n  grafana_password =\u003e '5ecretPassw0rd',\n  grafana_api_path =\u003e '/grafana/api',\n  type             =\u003e 'influxdb',\n  organization     =\u003e 'NewOrg',\n  url              =\u003e 'http://localhost:8086',\n  user             =\u003e 'admin',\n  password         =\u003e '1nFlux5ecret',\n  database         =\u003e 'graphite',\n  access_mode      =\u003e 'proxy',\n  is_default       =\u003e true,\n  json_data        =\u003e template('path/to/additional/config.json'),\n  secure_json_data =\u003e template('path/to/additional/secure/config.json')\n}\n```\n\nAvailable types are: influxdb, elasticsearch, graphite, cloudwatch, mysql, opentsdb, postgres and prometheus\n\n`organization` is used to set which organization a datasource will be created on. If this parameter is not set, it will default to organization ID 1 (Main Org. by default). If the default org is deleted, organizations will need to be specified.\n\nAccess mode determines how Grafana connects to the datasource, either `direct`\nfrom the browser, or `proxy` to send requests via grafana.\n\nSetting `basic_auth` to `true` will allow use of the `basic_auth_user` and `basic_auth_password` params.\n\nAuthentication is optional, as are `database` and `grafana_api_path`; additional `json_data` and `secure_json_data` can be provided to allow custom configuration options.\n\nExample:\nMake sure the `grafana-server` service is up and running before creating the `grafana_datasource` definition. One option is to use the `http_conn_validator` from the [healthcheck](https://forge.puppet.com/puppet/healthcheck) module\n\n```puppet\nhttp_conn_validator { 'grafana-conn-validator' :\n  host     =\u003e 'localhost',\n  port     =\u003e '3000',\n  use_ssl  =\u003e false,\n  test_url =\u003e '/public/img/grafana_icon.svg',\n  require  =\u003e Class['grafana'],\n}\n-\u003e grafana_datasource { 'influxdb':\n  grafana_url       =\u003e 'http://localhost:3000',\n  grafana_user      =\u003e 'admin',\n  grafana_password  =\u003e '5ecretPassw0rd',\n  type              =\u003e 'influxdb',\n  url               =\u003e 'http://localhost:8086',\n  user              =\u003e 'admin',\n  password          =\u003e '1nFlux5ecret',\n  database          =\u003e 'graphite',\n  access_mode       =\u003e 'proxy',\n  is_default        =\u003e true,\n  json_data         =\u003e template('path/to/additional/config.json'),\n}\n```\n\nNote that the `database` is dynamic, setting things other than \"database\" for separate types. Ex: for Elasticsearch it will set the Index Name.\n\n**`jsonData` Settings**\n\nNote that there are separate options for json_data / secure_json_data based on the type of datasource you create.\n\n##### **Elasticsearch**\n\n`esVersion` - Required, either 2 or 5, set as a bare number.\n\n`timeField` - Required. By default this is @timestamp, but without setting it in jsonData, the datasource won't work without refreshing it in the GUI.\n\n`timeInterval` - Optional. A lower limit for the auto group by time interval. Recommended to be set to write frequency, for example \"1m\" if your data is written every minute.\n\nExample:\n```puppet\njson_data =\u003e {\"esVersion\":5,\"timeField\":\"@timestamp\",\"timeInterval\":\"1m\"}\n```\n\n##### **CloudWatch**\n\n`authType` - Required. Options are `Access \u0026 Secret Key`, `Credentials File`, or `ARN`.\n\n-\"keys\" = Access \u0026 Secret Key\n\n-\"credentials\" = Credentials File\n\n-\"arn\" = ARN\n\n*When setting authType to `credentials`, the `database` param will set the Credentials Profile Name.*\n\n*When setting authType to `arn`, another jsonData value of `assumeRoleARN` is available, which is not required for other authType settings*\n\n`customMetricsNamespaces` - Optional. Namespaces of Custom Metrics, separated by commas within double quotes.\n\n`defaultRegion` - Required. Options are \"ap-northeast-(1 or 2)\", \"ap-southeast-(1 or 2)\", \"ap-south-1\", \"ca-central-1\", \"cn-north-1\", \"eu-central-1\", \"eu-west-(1 or 2)\", \"sa-east-(1 or 2)\", \"us-east-(1 or 2)\", \"us-gov-west-1\", \"us-west-(1 or 2)\".\n\n`timeField`\n\nExample:\n```puppet\n{\"authType\":\"arn\",\"assumeRoleARN\":\"arn:aws:iam:*\",\"customMetricsNamespaces\":\"Namespace1,Namespace2\",\"defaultRegion\":\"us-east-1\",\"timeField\":\"@timestamp\"}\n```\n\n##### **Graphite**\n\n`graphiteVersion` - Required. Available versions are `0.9` or `1.0`.\n\n`tlsAuth` - Set to `true` or `false`\n\n`tlsAuthWithCACert` - Set to `true` or `false`\n\nExample:\n```puppet\n{\"graphiteVersion\":\"0.9\",\"tlsAuth\":true,\"tlsAuthWithCACert\":false}\n```\n\n##### **OpenTSDB**\n\n`tsdbResolution` - Required. Options are `1` or `2`.\n\n  `1` = second\n\n  `2` = millisecond\n\n`tsdbVersion` - Required. Options are `1`, `2`, or `3`.\n\n  `1` \u0026nbsp;\u0026nbsp; = \u0026nbsp;\u0026nbsp; \u003c=2.1\n\n  `2` \u0026nbsp;\u0026nbsp; = \u0026nbsp;\u0026nbsp; ==2.2\n\n  `3` \u0026nbsp;\u0026nbsp; = \u0026nbsp;\u0026nbsp; ==2.3\n\nExample:\n```puppet\n{\"tsdbResolution:1,\"tsdbVersion\":3}\n```\n\n##### **InfluxDB**\n\nN/A\n\n##### **MySQL**\n\nN/A\n\n##### **Prometheus**\n\nN/A\n\n##### `grafana_plugin`\n\nAn example is provided for convenience; for more details, please view the\npuppet strings docs.\n\n```puppet\ngrafana_plugin { 'grafana-simple-json-datasource':\n  ensure =\u003e present,\n}\n```\n\nIt is possible to specify a custom plugin repository to install a plugin. This will use the --repo option for plugin installation with grafana_cli.\n\n```puppet\ngrafana_plugin { 'grafana-simple-json-datasource':\n  ensure    =\u003e present,\n  repo      =\u003e 'https://nexus.company.com/grafana/plugins',\n}\n```\n\nIt is also possible to specify a custom plugin url to install a plugin. This will use the --pluginUrl option for plugin installation with grafana_cli.\n\n```puppet\ngrafana_plugin { 'grafana-example-custom-plugin':\n  ensure     =\u003e present,\n  plugin_url =\u003e 'https://github.com/example/example-custom-plugin/zipball/v1.0.0'\n}\n```\n\nIf you need to enforce a specific version of an plugin you can use the package provider.\n\n```puppet\npackage { 'grafana-image-renderer':\n  ensure =\u003e '2.0.0',\n  provider =\u003e 'grafana',\n}\n```\n\nThe package provider also enables the possibility to use `latest` which will update plugins if there is a newer version.\n\n```puppet\npackage { 'grafana-image-renderer':\n  ensure =\u003e 'latest',\n  provider =\u003e 'grafana',\n}\n```\n\n##### `grafana_folder`\n\nCreates and manages Grafana folders via the API.\n\nThe following example creates a folder named 'folder1':\n```puppet\ngrafana_folder { 'folder1':\n  ensure            =\u003e present,\n  grafana_url       =\u003e 'http://localhost:3000',\n  grafana_api_path  =\u003e '/grafana/api',\n  grafana_user      =\u003e 'admin',\n  grafana_password  =\u003e '5ecretPassw0rd',\n}\n```\n`grafana_api_path` is only required if using sub-paths for the API\n\n##### `grafana::user`\n\nCreates and manages a global grafana user via the API.\n\n```puppet\ngrafana_user { 'username':\n  grafana_url       =\u003e 'http://localhost:3000',\n  grafana_api_path  =\u003e '/grafana/api',\n  grafana_user      =\u003e 'admin',\n  grafana_password  =\u003e '5ecretPassw0rd',\n  full_name         =\u003e 'John Doe',\n  password          =\u003e 'Us3r5ecret',\n  email             =\u003e 'john@example.com',\n  organizations     =\u003e {\n    'Example Org' =\u003e 'Editor',\n    'Main org.'   =\u003e 'Viewer',\n    'Another Org' =\u003e 'Admin',\n  },\n}\n```\n\n`grafana_api_path` is only required if using sub-paths for the API\n\nIf `organizations` is specified, the user's organizations will be managed.\nThese should be specified as a hash of organization names and roles.\n\nIf puppet is managing any of these organizations, they will be autorequired.\n\n##### `grafana::notification`\n\nCreates and manages a global alert notification channel via the API.\n\n```puppet\ngrafana_notification { 'channelname':\n  grafana_url       =\u003e 'http://localhost:3000',\n  grafana_api_path  =\u003e '/grafana/api',\n  grafana_user      =\u003e 'admin',\n  grafana_password  =\u003e '5ecretPassw0rd',\n\n  name              =\u003e 'channelname',\n  type              =\u003e 'email',\n  is_default        =\u003e false,\n  send_reminder     =\u003e false,\n  frequency         =\u003e '20m',\n  settings          =\u003e {\n              addresses    =\u003e \"alerts@example.com; it@example.com\"\n  }\n}\n```\n`grafana_api_path` is only required if using sub-paths for the API\n\nNotification types and related settingsi (cf doc Grafana : https://github.com/grafana/grafana/blob/master/docs/sources/alerting/notifications.md ) :\n   - email:\n       - addresses: \"example.com\"\n   - hipchat:\n       - apikey       : \"0a0a0a0a0a0a0a0a0a0a0a\"\n       - autoResolve  : true\n       - httpMethod   : \"POST\"\n       - uploadImage  : true\n       - url          : \"https://grafana.hipchat.com\"\n   - kafka:\n       - autoResolve   : true\n       - httpMethod    : \"POST\"\n       - kafkaRestProxy: \"http://localhost:8082\"\n       - kafkaTopic    : \"topic1\"\n       - uploadImage   : true\n   - LINE:\n       - autoResolve: true\n       - httpMethod : \"POST\"\n       - token      : \"token\"\n       - uploadImage: true\n   - teams (Microsoft Teams):\n       - autoResolve : true\n       - httpMethod  : \"POST\"\n       - uploadImage :true\n       - url         : \"http://example.com\"\n   - pagerduty:\n       - autoResolve    : true\n       - httpMethod     : POST\n       - integrationKey :\"0a0a0a0a0a\"\n       - uploadImage    : true\n   - prometheus-alertmanager:\n       - autoResolve : true\n       - httpMethod  : \"POST\"\n       - uploadImage : true\n       - url         : \"http://localhost:9093\"\n   - sensu:\n       - autoResolve : true\n       - handler     : \"default\",\n       - httpMethod  : \"POST\"\n       - uploadImage : true\n       - url         : \"http://sensu-api.local:4567/results\"\n   - slack:\n       - autoResolve : true\n       - httpMethod  : \"POST\"\n       - uploadImage : true\n       - url         : \"http://slack.com/\"\n       - token       : \"0a0a0a0a0a0a0a0a0a0a0a\"\n   - threema:\n       - api_secret  : \"0a0a0a0a0a0a0a0a0a0a0a\"\n       - autoResolve : true\n       - gateway_id  : \"*3MAGWID\"\n       - httpMethod  : \"POST\"\n       - recipient_id: \"YOUR3MID\"\n       - uploadImage : true\n   - discord:\n       - autoResolve : true,\n       - httpMethod  : \"POST\"\n       - uploadImage : true\n       - url         : \"https://example.com\"\n   - webhook:\n       - autoResolve : true\n       - httpMethod  : \"POST\"\n       - uploadImage : false\n       - url         : \"http://localhost:8080\"\n   - telegram:\n       - autoResolve : true\n       - bottoken    : \"0a0a0a0a0a0a\"\n       - chatid      : \"789789789\"\n       - httpMethod  : \"POST\"\n       - uploadImage : true\n\n#### Provisioning Grafana\n\n[Grafana documentation on\nprovisioning](http://docs.grafana.org/administration/provisioning/).\n\nThis module will provision grafana by placing yaml files into\n`/etc/grafana/provisioning/datasources` and\n`/etc/grafana/provisioning/dashboards` by default.\n\n##### Example datasource\n\nA puppet hash example for Prometheus. The module will place the hash\nas a yaml file into `/etc/gafana/provisioning/datasources/puppetprovisioned.yaml`.\n\n```puppet\nclass { 'grafana':\n  provisioning_datasources =\u003e {\n    apiVersion  =\u003e 1,\n    datasources =\u003e [\n      {\n        name      =\u003e 'Prometheus',\n        type      =\u003e 'prometheus',\n        access    =\u003e 'proxy',\n        url       =\u003e 'http://localhost:9090/prometheus',\n        isDefault =\u003e true,\n      },\n    ],\n  }\n}\n```\n\nHere is the same configuration example as a hiera hash.\n\n```yaml\ngrafana::provisioning_datasources:\n  apiVersion: 1\n  datasources:\n    - name: 'Prometheus'\n      type: 'prometheus'\n      access: 'proxy'\n      url: 'http://localhost:9090/prometheus'\n      isDefault: true\n```\n\n##### Example dashboard\n\nAn example puppet hash for provisioning dashboards. The module will\nplace the hash as a yaml file into\n`/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml` by default. More details follow the examples.\n\n```puppet\nclass { 'grafana':\n  provisioning_dashboards =\u003e {\n    apiVersion =\u003e 1,\n    providers  =\u003e [\n      {\n        name            =\u003e 'default',\n        orgId           =\u003e 1,\n        folder          =\u003e '',\n        type            =\u003e 'file',\n        disableDeletion =\u003e true,\n        options         =\u003e {\n          path         =\u003e '/var/lib/grafana/dashboards',\n          puppetsource =\u003e 'puppet:///modules/my_custom_module/dashboards',\n        },\n      },\n    ],\n  }\n}\n```\n\nHere is the same configuraiton example as a hiera hash.\n\n```yaml\ngrafana::provisioning_dashboards:\n  apiVersion: 1\n  providers:\n    - name: 'default'\n      orgId: 1\n      folder: ''\n      type: file\n      disableDeletion: true\n      options:\n        path: '/var/lib/grafana/dashboards'\n        puppetsource: 'puppet:///modules/my_custom_module/dashboards'\n```\n\nIn both examples above a non-grafana option named `puppetsource` has\nbeen used. When this module finds that the provisioning_dashboards hash\ncontains keys `path` and `puppetsource` in the `options` subhash, it\nwill do the following.\n* It will create the path found in `options['path']`. Note: puppet\n  will only create the final directory of the path unless the\n  parameter `create_subdirs_provisioning` is set to true: this defaults\n  to false.\n* It will use `puppetsource` as the file resource's 'source' for the\n  directory.\n* It removes the `puppetsource` key from the `options` subhash, so the\n  subsequent yaml file for gafana does not contain this key. (The\n  `path` key will remain.)\n\nThis feature allows you to define a custom module, and place any\ndashboards you want provisioned in the its `files/` directory. In the\nexample above you would put dashboards into\n`my_custom_module/files/dashboards` and puppet-grafana will create\n`/var/lib/grafana/dashboards` and provision it with the contents of\n`my_custom_module/files/dashboards`.\n\nPuppet's file resource may also be given a `file://` URI which may\npoint to a locally available directory on the filesystem, typically\nthe filesystem of the puppetserver/master. Thus you may specify a\nlocal directory with grafana dashboards you wish to provision into\ngrafana.\n\n##### Provisioning with dashboards from grafana.com\n\nGrafanaLabs provides lots of [dashboards that may be reused](https://grafana.com/grafana/dashboards).\nThose ones are **not directly usable** for provisioning (this is\na Grafana issue, not a Puppet one).\n\nIn order to have a \"provisionable\" dashboard in JSON format, you have\nto prepare it before adding it in your Puppet code. Here are the steps\nto follow:\n\n1. Use a Grafana instance\n1. Import the desired dashboard\n1. Define its datasource\n1. From the dashboard view:\n    * Click the \"Share dashboard\" icon (top left corner of screen)\n    * Select the \"Export\" tab,\n    * Activate \"Export for sharing externally\"\n    * Click \"Save to file\"\n1. In the JSON file:\n    * Remove the keys `__imports` and `__requires`\n    * Replace all `${DS_PROMETHEUS}` by your datasource name\n1. Once saved, you may place this JSON file in your\n   `puppet:///modules/my_custom_module/dashboards` directory\n\n**Note:**\n\nThis procedure have been tested with Grafana 6.x. It may not work for\n any dashboard, depending on how it's been coded.\n\nDashboards known to be \"provisionable\":\n\n* [Node Exporter Server Metric](https://grafana.com/dashboards/405)\n* [Prometheus Blackbox Exporter](https://grafana.com/dashboards/7587)\n\nDashboards known not to be \"provisionable\":\n\n* [HTTP Services Status](https://grafana.com/dashboards/4859)\n\n## Tasks\n\n### `change_grafana_admin_password`\n\n`old_password`: the old admin password\n\n`new_password`: the password you want to use for the admin user\n\n`uri`: `http` or `https`\n\n`port`: the port Grafana runs on locally\n\nThis task can be used to change the password for the admin user in grafana\n\n## Limitations\n\nThis module has been tested on every operating system in the metadata.json, using\neach of the 'archive', 'docker' and 'package' installation methods. Other\nconfigurations should work with minimal, if any, additional effort.\n\n## Development\n\nThis module is a fork of\n[bfraser/grafana](https://github.com/bfraser/puppet-grafana) maintained by [Vox\nPupuli](https://voxpupuli.org/). Vox Pupuli welcomes new contributions to this\nmodule, especially those that include documentation and rspec tests. We are\nhappy to provide guidance if necessary.\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for more details.\n\n### Authors\n* Bill Fraser \u003cfraser@pythian.com\u003e\n* Vox Pupuli Team\n\n## Copyright and License\n\nCopyright (C) 2015 Bill Fraser\n\nBill can be contacted at: fraser@pythian.com\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n  \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpupuli%2Fpuppet-grafana","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoxpupuli%2Fpuppet-grafana","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpupuli%2Fpuppet-grafana/lists"}