Puppet Class: grafana

Defined in:
manifests/init.pp

Summary

Installs and configures Grafana.

Overview

Examples:

Using the Class

class { 'grafana':
  install_method  => 'docker',
}

Parameters:

  • archive_source (Optional[String]) (defaults to: undef)

    Download location of tarball to be used with the ‘archive’ install method.

  • cfg_location (String)

    Location of the configuration file.

  • ldap_cfg (Optional[Variant[Hash,Array[Hash],Sensitive[Hash],Sensitive[Array[Hash]]]]) (defaults to: undef)
  • container_cfg (Boolean) (defaults to: false)

    Determines whether a configuration file should be generated when using the ‘docker’ install method. If true, use the ‘cfg` and `cfg_location` parameters to control creation of the file.

  • container_params (Hash) (defaults to: {})

    Parameters to use when creating the Docker container. For use with the ‘docker’ install method. Refer to documentation of the ‘docker::run` resource in the `garethr-docker` module for details of available parameters.

  • data_dir (String) (defaults to: '/var/lib/grafana')

    The directory Grafana will use for storing its data.

  • install_dir (String) (defaults to: '/usr/share/grafana')

    Installation directory to be used with the ‘archive’ install method.

  • install_method (Enum['archive', 'docker', 'package', 'repo'])

    Set to ‘archive’ to install Grafana using the tar archive. Set to ‘docker’ to install Grafana using the official Docker container. Set to ‘package’ to install Grafana using .deb or .rpm packages. Set to ‘repo’ to install Grafana using an apt or yum repository.

  • manage_package_repo (Boolean)

    If true this will setup the official grafana repositories on your host.

  • package_name (String)

    The name of the package managed with the ‘package’ install method.

  • package_source (Optional[String]) (defaults to: undef)

    Download location of package to be used with the ‘package’ install method.

  • service_name (String)

    The name of the service managed with the ‘archive’ and ‘package’ install methods.

  • version (String) (defaults to: 'installed')

    The version of Grafana to install and manage.

  • repo_name (Enum['stable', 'beta', 'custom']) (defaults to: 'stable')

    When using ‘repo’ install_method, the repo to look for packages in. Set to ‘stable’ to install only stable versions Set to ‘beta’ to install beta versions Set to ‘custom’ to install from custom repo. Use full URL

  • repo_gpg_key_url (Stdlib::HTTPUrl) (defaults to: 'https://packages.grafana.com/gpg.key')

    When using ‘repo’ install_method, the repo_gpg_key_url to look for the gpg signing key of the repo.

  • repo_key_id (String[1]) (defaults to: 'B53AE77BADB630A683046005963FA27710458545')

    When using ‘repo’ install_method, the repo_key_id of the repo_gpg_key_url key on Debian based systems.

  • repo_release (Optional[String[1]]) (defaults to: undef)

    Optional value, needed on Debian based systems. If repo name is set to custom, used to identify the release of the repo. No default value.

  • repo_url (Optional[Stdlib::HTTPUrl])

    When using ‘repo’ install_method, the repo_url to look for packages in. Set to a custom string value to install from a custom repo.

  • plugins (Hash) (defaults to: {})

    Plugins to be passed to ‘create_resources`, wraps around the `grafana_plugin` resource.

  • provisioning_dir (Stdlib::Absolutepath) (defaults to: '/etc/grafana/provisioning')

    Path to the grafana provisioning dir e.g /etc/grafana/provisioning

  • provisioning_dashboards (Hash) (defaults to: {})

    Dashboards to provision into grafana. grafana > v5.0.0 required. Will be converted into YAML and used by grafana to provision dashboards.

  • provisioning_datasources (Hash) (defaults to: {})

    Datasources to provision into grafana, grafana > v5.0.0 required. Will be converted into YAML and used by granfana to configure datasources.

  • provisioning_dashboards_file (Stdlib::Absolutepath) (defaults to: "${provisioning_dir}/dashboards/puppetprovisioned.yaml")

    Fully qualified path to place the provisioning file for dashboards, only used if provisioning_dashboards is specified.

  • provisioning_datasources_file (Stdlib::Absolutepath) (defaults to: "${provisioning_dir}/datasources/puppetprovisioned.yaml")

    Fully qualified path to place the provisioning file for datasources, only used if provisioning_datasources is specified.

  • create_subdirs_provisioning (Boolean) (defaults to: false)

    If true puppet will create any subdirectories in the given path when provisioning dashboards.

  • sysconfig_location (Optional[String])

    Location of the sysconfig file for the environment of the grafana-server service. This is only used when the install_method is ‘package’ or ‘repo’.

  • sysconfig (Optional[Hash]) (defaults to: undef)

    Environment variables for the grafana-server service

    Example:

    sysconfig => { 'http_proxy' => 'http://proxy.example.com/' }
    
  • ldap_servers (Hash[String[1], Hash]) (defaults to: {})

    Servers to be passed to ‘create_resources`, wraps around the `grafana_ldap_server` resource.

  • ldap_group_mappings (Hash[String[1], Hash]) (defaults to: {})

    ldap_group_mappings Mappings to be passed to ‘create_resources`, wraps around the `grafana_ldap_group_mapping` resource.

  • toml_manage_package (Boolean) (defaults to: true)

    ruby-toml is required to generate the TOML-based LDAP config for Grafana. Set to false if you manage package- or gem-install somewhere else.

  • toml_package_name (String[1]) (defaults to: 'ruby-toml')

    Name of the software-package providing the TOML parser library.

  • toml_package_ensure (String[1]) (defaults to: 'present')

    Ensure the package-resource - e.g. installed, absent, etc. puppet.com/docs/puppet/latest/types/package.html#package-attribute-ensure

  • toml_package_provider (Optional[String[1]]) (defaults to: undef)

    The package-provider used to install the TOML parser library.

  • docker_image (String) (defaults to: 'grafana/grafana')

    name of the docker image that provides grafana

  • docker_ports (String) (defaults to: '3000:3000')

    ports docker should expose

  • rpm_iteration (String) (defaults to: '1')

    explicit Iteration / epoch for the rpm

  • cfg (Variant[Hash,Sensitive[Hash]]) (defaults to: {})

    The whole grafana configuration



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'manifests/init.pp', line 147

class grafana (
  String $cfg_location,
  Enum['archive', 'docker', 'package', 'repo'] $install_method,
  Boolean $manage_package_repo,
  String $package_name,
  Optional[Stdlib::HTTPUrl] $repo_url,
  String $service_name,
  Optional[String] $sysconfig_location,
  Optional[String] $archive_source = undef,
  Variant[Hash,Sensitive[Hash]] $cfg = {},
  Optional[Variant[Hash,Array[Hash],Sensitive[Hash],Sensitive[Array[Hash]]]] $ldap_cfg = undef,
  Boolean $container_cfg = false,
  Hash $container_params = {},
  String $docker_image = 'grafana/grafana',
  String $docker_ports = '3000:3000',
  String $data_dir = '/var/lib/grafana',
  String $install_dir = '/usr/share/grafana',
  Optional[String] $package_source = undef,
  Enum['stable', 'beta', 'custom'] $repo_name = 'stable',
  String[1] $repo_key_id = 'B53AE77BADB630A683046005963FA27710458545',
  Optional[String[1]] $repo_release = undef,
  String $rpm_iteration = '1',
  String $version = 'installed',
  Hash $plugins = {},
  Hash $provisioning_dashboards = {},
  Hash $provisioning_datasources = {},
  Stdlib::Absolutepath $provisioning_dir = '/etc/grafana/provisioning',
  Stdlib::Absolutepath $provisioning_dashboards_file = "${provisioning_dir}/dashboards/puppetprovisioned.yaml",
  Stdlib::Absolutepath $provisioning_datasources_file = "${provisioning_dir}/datasources/puppetprovisioned.yaml",
  Boolean $create_subdirs_provisioning = false,
  Optional[Hash] $sysconfig = undef,
  Hash[String[1], Hash] $ldap_servers = {},
  Hash[String[1], Hash] $ldap_group_mappings = {},
  Boolean $toml_manage_package = true,
  String[1] $toml_package_name = 'ruby-toml',
  String[1] $toml_package_ensure = 'present',
  Optional[String[1]] $toml_package_provider = undef,
  Stdlib::HTTPUrl $repo_gpg_key_url = 'https://packages.grafana.com/gpg.key',
) {
  contain grafana::install
  contain grafana::config
  contain grafana::service

  Class['grafana::install']
  -> Class['grafana::config']
  -> Class['grafana::service']

  create_resources(grafana_plugin, $plugins)
  # Dependency added for Grafana_plugins to ensure it runs at the
  # correct time.
  Class['grafana::config'] -> Grafana_Plugin <| |> ~> Class['grafana::service']

  create_resources('grafana_ldap_server', $ldap_servers)
  create_resources('grafana_ldap_group_mapping', $ldap_group_mappings)
}