Puppet Class: thanos

Defined in:
manifests/init.pp

Summary

This module manages Thanos

Overview

Init class of Thanos module. It can installes Thanos binaries and manages components as single Service.

Examples:

include thanos

Parameters:

  • version (Pattern[/\d+\.\d+\.\d+/])
  • os (String) (defaults to: downcase($facts['kernel']))

    Operating system.

  • manage_sidecar (Boolean) (defaults to: false)

    Whether to create a service to run Sidecar.

  • manage_query (Boolean) (defaults to: false)

    Whether to create a service to run Query.

  • manage_query_frontend (Boolean) (defaults to: false)

    Whether to create a service to run Query Frontend.

  • manage_rule (Boolean) (defaults to: false)

    Whether to create a service to run Rule.

  • manage_store (Boolean) (defaults to: false)

    Whether to create a service to run Store.

  • manage_compact (Boolean) (defaults to: false)

    Whether to create a service to run Compact.

  • manage_receive (Boolean) (defaults to: false)

    Whether to create a service to run Receiver.

  • manage_tools_bucket_web (Boolean) (defaults to: false)

    Whether to create a service to run Bucket Web interface.

  • install_method (Enum['url', 'package', 'none']) (defaults to: 'url')

    Installation method: url or package (only url is supported currently).

  • package_ensure (Enum['present', 'absent', 'latest']) (defaults to: 'latest')

    If package, then use this for package ensure default ‘latest’.

  • package_name (String) (defaults to: 'thanos')

    Thanos package name - not available yet.

  • base_url (Stdlib::HTTPUrl) (defaults to: 'https://github.com/thanos-io/thanos/releases/download')

    Base URL for thanos.

  • download_extension (String) (defaults to: 'tar.gz')

    Extension of Thanos binaries archive.

  • download_url (Optional[Stdlib::HTTPUrl]) (defaults to: undef)

    Complete URL corresponding to the Thanos release, default to undef.

  • base_dir (Stdlib::Absolutepath) (defaults to: '/opt')

    Base directory where Thanos is extracted.

  • bin_dir (Stdlib::Absolutepath) (defaults to: '/usr/local/bin')

    Directory where binaries are located.

  • config_dir (Stdlib::Absolutepath) (defaults to: '/etc/thanos')

    Directory where configuration are located.

  • purge_config_dir (Boolean) (defaults to: true)

    Purge configuration directory.

  • tsdb_path (Stdlib::Absolutepath) (defaults to: '/data')

    Data directory of TSDB.

  • manage_user (Boolean) (defaults to: true)

    Whether to create user for thanos or rely on external code for that.

  • manage_group (Boolean) (defaults to: true)

    Whether to create user for thanos or rely on external code for that.

  • user (String) (defaults to: 'thanos')

    User running thanos.

  • group (String) (defaults to: 'thanos')

    Group under which thanos is running.

  • usershell (Stdlib::Absolutepath) (defaults to: '/bin/false')

    if requested, we create a user for thanos. The default shell is false. It can be overwritten to any valid path.

  • extra_groups (Array[String]) (defaults to: [])

    Add other groups to the managed user.

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

    Custom command passed to the archive resource to extract the downloaded archive.

  • manage_storage_config (Boolean) (defaults to: false)

    Whether to manage storage configuration file.

  • storage_config_file (Stdlib::Absolutepath) (defaults to: "${config_dir}/storage.yaml")

    Path to storage configuration file.

  • storage_config (Hash[String, Data]) (defaults to: {})

    Storage configuration.

    type: one of ['S3', 'GCS', 'AZURE', 'SWIFT', 'COS', 'ALIYUNOSS', 'FILESYSTEM']
    config: storage typed configuration in Hash[String, Data]
    
  • manage_tracing_config (Boolean) (defaults to: false)

    Whether to manage tracing configuration file

  • tracing_config_file (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path to tracing configuration file.

  • tracing_config (Hash[String, Data]) (defaults to: {})

    Tracing configuration.

    type: one of ['JAEGER', 'STACKDRIVER', 'ELASTIC_APM', 'LIGHTSTEP']
    config: tracing typed configuration in Hash[String, Data]
    
  • manage_index_cache_config (Boolean) (defaults to: false)

    Whether to manage index cache configuration file

  • index_cache_config_file (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path to index cache configuration file.

  • index_cache_config (Hash[String, Data]) (defaults to: {})

    Index cache configuration.

    type: one of ['IN-MEMORY', 'MEMCACHED']
    config: index cache typed configuration in Hash[String, Data]
    


87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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
202
203
204
205
206
207
# File 'manifests/init.pp', line 87

class thanos (
  Pattern[/\d+\.\d+\.\d+/]            $version,
  String                              $os                        = downcase($facts['kernel']),
  Boolean                             $manage_sidecar            = false,
  Boolean                             $manage_query              = false,
  Boolean                             $manage_query_frontend     = false,
  Boolean                             $manage_rule               = false,
  Boolean                             $manage_store              = false,
  Boolean                             $manage_compact            = false,
  Boolean                             $manage_receive            = false,
  Boolean                             $manage_tools_bucket_web   = false,

  # Installation
  Enum['url', 'package', 'none']      $install_method            = 'url',
  Enum['present', 'absent', 'latest'] $package_ensure            = 'latest',
  String                              $package_name              = 'thanos',
  Stdlib::HTTPUrl                     $base_url                  = 'https://github.com/thanos-io/thanos/releases/download',
  String                              $download_extension        = 'tar.gz',
  Optional[Stdlib::HTTPUrl]           $download_url              = undef,
  Stdlib::Absolutepath                $base_dir                  = '/opt',
  Stdlib::Absolutepath                $bin_dir                   = '/usr/local/bin',
  Stdlib::Absolutepath                $config_dir                = '/etc/thanos',
  Boolean                             $purge_config_dir          = true,
  Stdlib::Absolutepath                $tsdb_path                 = '/data',

  # User Management
  Boolean                             $manage_user               = true,
  Boolean                             $manage_group              = true,
  String                              $user                      = 'thanos',
  String                              $group                     = 'thanos',
  Stdlib::Absolutepath                $usershell                 = '/bin/false',
  Array[String]                       $extra_groups              = [],
  Optional[String]                    $extract_command           = undef,

  # Configuration
  Boolean                             $manage_storage_config     = false,
  Stdlib::Absolutepath                $storage_config_file       = "${config_dir}/storage.yaml",
  Hash[String, Data]                  $storage_config            = {},
  Boolean                             $manage_tracing_config     = false,
  Optional[Stdlib::Absolutepath]      $tracing_config_file       = undef,
  Hash[String, Data]                  $tracing_config            = {},
  Boolean                             $manage_index_cache_config = false,
  Optional[Stdlib::Absolutepath]      $index_cache_config_file   = undef,
  Hash[String, Data]                  $index_cache_config        = {},
) {
  $bin_path = "${bin_dir}/thanos"

  $notify_services = {
    'sidecar'        => $manage_sidecar,
    'query'          => $manage_query,
    'query-frontend' => $manage_query_frontend,
    'rule'           => $manage_rule,
    'store'          => $manage_store,
    'compact'        => $manage_compact,
    'receive'        => $manage_receive,
    'bucket-web'     => $manage_tools_bucket_web,
  }.filter |String $key, Boolean $value| {
    $value
  }.map |String $key, Boolean $value| {
    Service["thanos-${key}"]
  }

  case $facts['os']['architecture'] {
    'x86_64', 'amd64': { $real_arch = 'amd64' }
    'aarch64':         { $real_arch = 'arm64' }
    default:           {
      fail("Unsupported kernel architecture: ${facts['os']['architecture']}")
    }
  }

  if $download_url {
    $real_download_url = $download_url
  } else {
    $real_download_url = "${base_url}/v${version}/thanos-${version}.${os}-${real_arch}.${download_extension}"
  }

  include thanos::install
  include thanos::config

  Class['thanos::install'] -> Class['thanos::config']

  if $manage_sidecar {
    include thanos::sidecar
    Class['thanos::config'] -> Class['thanos::sidecar']
  }

  if $manage_query {
    include thanos::query
    Class['thanos::config'] -> Class['thanos::query']
  }

  if $manage_query_frontend {
    include thanos::query_frontend
    Class['thanos::config'] -> Class['thanos::query_frontend']
  }

  if $manage_rule {
    include thanos::rule
    Class['thanos::config'] -> Class['thanos::rule']
  }

  if $manage_store {
    include thanos::store
    Class['thanos::config'] -> Class['thanos::store']
  }

  if $manage_compact {
    include thanos::compact
    Class['thanos::config'] -> Class['thanos::compact']
  }

  if $manage_receive {
    include thanos::receive
    Class['thanos::config'] -> Class['thanos::receive']
  }

  if $manage_tools_bucket_web {
    include thanos::tools::bucket_web
    Class['thanos::config'] -> Class['thanos::tools::bucket_web']
  }
}