Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 415ecdc

Browse files
authored
Merge pull request #194 from m0dular/SUP-2754-sles_support
(Sup-2754) Adding SLES support
2 parents c946f1e + f64c54f commit 415ecdc

24 files changed

+266
-131
lines changed

.fixtures.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ fixtures:
44
apt: https://github.com/puppetlabs/puppetlabs-apt.git
55
inifile: https://github.com/puppetlabs/puppetlabs-inifile.git
66
grafana: https://github.com/voxpupuli/puppet-grafana.git
7+
archive: https://github.com/voxpupuli/puppet-archive.git
8+
systemd: https://github.com/voxpupuli/puppet-systemd.git
79
yumrepo:
810
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
911
puppet_version: ">= 6.0.0"

data/common.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ puppet_metrics_dashboard::grafana_version: "8.2.2"
3636
puppet_metrics_dashboard::overwrite_dashboards_file: "/opt/puppetlabs/puppet/cache/state/overwrite_dashboards_disabled"
3737

3838
puppet_metrics_dashboard::grafana_config: {}
39-
39+
puppet_metrics_dashboard::grafana_manage_repo: false

data/os/Suse.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
puppet_metrics_dashboard::manage_repos: false
3+
puppet_metrics_dashboard::influx_db_service_name: 'influxdb'
4+
puppet_metrics_dashboard::influx_archive_source: 'https://dl.influxdata.com/influxdb/releases/influxdb-1.8.1_linux_amd64.tar.gz'
5+
puppet_metrics_dashboard::grafana_install_method: 'package'
6+
puppet_metrics_dashboard::grafana_manage_repo: false

files/influxdb.service

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Managed by Puppet!
2+
# If you modify this, please also make sure to edit init.sh
3+
4+
[Unit]
5+
Description=InfluxDB is an open-source, distributed, time series database
6+
Documentation=https://docs.influxdata.com/influxdb/
7+
After=network-online.target
8+
9+
[Service]
10+
User=influxdb
11+
Group=influxdb
12+
LimitNOFILE=65536
13+
EnvironmentFile=-/etc/default/influxdb
14+
ExecStart=/opt/influxdb/usr/bin/influxd -config /opt/influxdb/etc/influxdb/influxdb.conf $INFLUXD_OPTS
15+
KillMode=control-group
16+
Restart=on-failure
17+
18+
[Install]
19+
WantedBy=multi-user.target
20+
Alias=influxd.service

manifests/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
master_list => $puppet_metrics_dashboard::master_list,
1414
}),
1515
notify => Service[$puppet_metrics_dashboard::influx_db_service_name],
16-
require => Package['influxdb'],
16+
require => Class['puppet_metrics_dashboard::install'],
1717
}
1818
}
1919
}

manifests/grafana.pp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@
5151
}).merge($ldap_cfg).merge($puppet_metrics_dashboard::grafana_config) # Merge any custom config over the top finally
5252

5353
class { 'grafana':
54-
install_method => 'repo',
55-
manage_package_repo => false,
54+
install_method => $puppet_metrics_dashboard::grafana_install_method,
55+
manage_package_repo => $puppet_metrics_dashboard::grafana_manage_repo,
56+
archive_source => $puppet_metrics_dashboard::grafana_archive_source,
5657
version => $puppet_metrics_dashboard::grafana_version,
5758
cfg => $_grafana_cfg,
5859
require => Service[$puppet_metrics_dashboard::influx_db_service_name],

manifests/init.pp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
# The password for the InfluxDB `admin` user.
5959
# Defaults to `puppet`
6060
#
61+
# @param influx_archive_source
62+
# URL if you want to install influx from tar.gz file
63+
#
6164
# @param telegraf_db_name
6265
# The InfluxDB database where Telegraf metrics are stored.
6366
#
@@ -116,6 +119,20 @@
116119
# Hash of arbitrary configuration settings to pass to Grafana.
117120
# These are added to `grafana.ini` with top-level keys becoming sections and their key-value children becoming settings.
118121
#
122+
# @param grafana_manage_repo
123+
# Whether to configure apt / yum repositories for grafana packages.
124+
#
125+
# @param grafana_archive_source
126+
# URL if you want to install grafana from tar.gz file
127+
#
128+
# @param grafana_install_method
129+
# grafana module allows to specify the installation method.
130+
# Set to 'archive' to install Grafana using the tar archive.
131+
# Set to 'docker' to install Grafana using the official Docker container.
132+
# Set to 'package' to install Grafana using .deb or .rpm packages.
133+
# Set to 'repo' to install Grafana using an apt or yum repository.
134+
# Defaults to 'package'.
135+
#
119136
# @example Grafana with no login
120137
# class { 'puppet_metrics_dashboard':
121138
# grafana_config => {
@@ -208,7 +225,6 @@
208225
String $influx_db_password,
209226

210227
String $telegraf_db_name,
211-
Optional[String[1]] $telegraf_db_retention_duration = undef,
212228
String[2] $telegraf_agent_interval,
213229
String[2] $http_response_timeout,
214230
String[2] $pg_query_interval,
@@ -228,14 +244,21 @@
228244

229245
Hash $grafana_config,
230246

247+
Boolean $grafana_manage_repo = $manage_repos,
248+
Enum['docker', 'archive', 'package', 'repo'] $grafana_install_method = 'repo',
249+
231250
Puppet_metrics_dashboard::HostList $master_list = puppet_metrics_dashboard::localhost_or_hosts_with_pe_profile('master'),
232251
Puppet_metrics_dashboard::HostList $puppetdb_list = puppet_metrics_dashboard::localhost_or_hosts_with_pe_profile('puppetdb'),
233252
Puppet_metrics_dashboard::HostList $postgres_host_list = puppet_metrics_dashboard::localhost_or_hosts_with_pe_profile('database'),
234253

235254
Puppet_metrics_dashboard::Puppetdb_metric $puppetdb_metrics = puppet_metrics_dashboard::puppetdb_metrics(),
255+
256+
Optional[String[1]] $telegraf_db_retention_duration = undef,
257+
Optional[Stdlib::Httpsurl] $influx_archive_source = undef,
258+
Optional[Stdlib::Httpsurl] $grafana_archive_source = undef,
236259
) {
237260

238-
unless $facts['os']['family'] =~ /^(RedHat|Debian)$/ {
261+
unless $facts['os']['family'] =~ /^(RedHat|Debian|Suse)$/ {
239262
fail("Installation on ${facts['os']['family']} is not supported")
240263
}
241264

manifests/install.pp

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#
55
# @api private
66
class puppet_metrics_dashboard::install {
7-
package { 'influxdb':
8-
ensure => present,
9-
}
107

118
$_chronograf_ensure = $puppet_metrics_dashboard::enable_chronograf ? {
129
true => present,
@@ -18,11 +15,44 @@
1815
default => absent
1916
}
2017

21-
package { 'kapacitor':
22-
ensure => $_kapacitor_ensure,
23-
}
18+
case $facts['os']['family'] {
19+
'Suse': {
20+
file { '/opt/influxdb':
21+
ensure => directory,
22+
}
23+
archive { '/tmp/influxdb.tar.gz':
24+
ensure => present,
25+
extract => true,
26+
extract_command => 'tar xfz %s --strip-components=2',
27+
extract_path => '/opt/influxdb',
28+
source => $puppet_metrics_dashboard::influx_archive_source,
29+
cleanup => true,
30+
}
31+
group { 'influxdb':
32+
ensure => present,
33+
}
34+
user { 'influxdb':
35+
ensure => present,
36+
gid => 'influxdb',
37+
}
38+
file { '/var/lib/influxdb':
39+
ensure => directory,
40+
owner => 'influxdb',
41+
group => 'influxdb',
42+
}
43+
}
44+
default: {
45+
package { 'influxdb':
46+
ensure => present,
47+
}
48+
49+
package { 'kapacitor':
50+
ensure => $_kapacitor_ensure,
51+
}
2452

25-
package { 'chronograf':
26-
ensure => $_chronograf_ensure,
53+
package { 'chronograf':
54+
ensure => $_chronograf_ensure,
55+
}
56+
}
2757
}
2858
}

manifests/post_start_configs.pp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,45 @@
55
#
66
# @api private
77
class puppet_metrics_dashboard::post_start_configs {
8+
Exec {
9+
path => ['/usr/bin', '/opt/influxdb/usr/bin', '/usr/local/bin', '/bin']
10+
}
811
# Fix a timing issue where influxdb does not start fully before creating users
912
exec { 'wait for influxdb':
1013
command => '/bin/sleep 10',
11-
unless => '/usr/bin/influx -execute "SHOW DATABASES"',
14+
unless => "influx -execute \"SHOW DATABASES\"",
1215
require => Service[$puppet_metrics_dashboard::influx_db_service_name],
1316
}
1417

1518
# lint:ignore:140chars
1619
exec { 'create influxdb admin user':
17-
command => "/usr/bin/influx -execute \"CREATE USER admin WITH PASSWORD '${puppet_metrics_dashboard::influx_db_password}' WITH ALL PRIVILEGES\"",
18-
unless => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \'show users\' | grep \'admin true\'",
20+
command => "influx -execute \"CREATE USER admin WITH PASSWORD '${puppet_metrics_dashboard::influx_db_password}' WITH ALL PRIVILEGES\"",
21+
unless => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \'show users\' | grep \'admin true\'",
1922
require => Exec['wait for influxdb'],
2023
}
2124
# lint:endignore
2225

2326
$puppet_metrics_dashboard::influxdb_database_name.each |$db_name| {
2427
# lint:ignore:140chars
2528
exec { "create influxdb puppet_metrics database ${db_name}":
26-
command => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"create database ${db_name}\"",
27-
unless => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \'show databases\' | grep ${db_name}",
29+
command => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"create database ${db_name}\"",
30+
unless => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \'show databases\' | grep ${db_name}",
2831
require => Exec['create influxdb admin user'],
2932
}
30-
# lint:endignore
3133
}
3234

3335
if $puppet_metrics_dashboard::telegraf_db_retention_duration =~ NotUndef {
34-
exec { "create default telegraf database retention policy":
35-
command => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"CREATE RETENTION POLICY telegraf_default ON ${puppet_metrics_dashboard::telegraf_db_name} DURATION ${puppet_metrics_dashboard::telegraf_db_retention_duration} REPLICATION 1 DEFAULT\"",
36-
unless => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"SHOW RETENTION POLICIES ON ${puppet_metrics_dashboard::telegraf_db_name}\" | grep -w telegraf_default",
36+
exec { 'create default telegraf database retention policy':
37+
command => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"CREATE RETENTION POLICY telegraf_default ON ${puppet_metrics_dashboard::telegraf_db_name} DURATION ${puppet_metrics_dashboard::telegraf_db_retention_duration} REPLICATION 1 DEFAULT\"",
38+
unless => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"SHOW RETENTION POLICIES ON ${puppet_metrics_dashboard::telegraf_db_name}\" | grep -w telegraf_default",
3739
require => Exec["create influxdb puppet_metrics database ${puppet_metrics_dashboard::telegraf_db_name}"],
3840
}
3941
} else {
40-
exec { "drop existing retention policy if ever created":
41-
command => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"DROP RETENTION POLICY telegraf_default ON ${puppet_metrics_dashboard::telegraf_db_name}\"",
42-
onlyif => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"SHOW RETENTION POLICIES ON ${puppet_metrics_dashboard::telegraf_db_name}\" | grep -w telegraf_default",
42+
exec { 'drop existing retention policy if ever created':
43+
command => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"DROP RETENTION POLICY telegraf_default ON ${puppet_metrics_dashboard::telegraf_db_name}\"",
44+
onlyif => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"SHOW RETENTION POLICIES ON ${puppet_metrics_dashboard::telegraf_db_name}\" | grep -w telegraf_default",
4345
}
46+
# lint:endignore
4447
}
4548

4649
$_uri = $puppet_metrics_dashboard::use_dashboard_ssl ? {

manifests/profile/compiler.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
}],
4040
notify => Service['telegraf'],
41-
require => Package['telegraf'],
41+
require => Class['telegraf::install'],
4242
}
4343

4444
if $facts['pe_server_version'] {
@@ -52,7 +52,7 @@
5252
'timeout' => $timeout,
5353
}],
5454
notify => Service['telegraf'],
55-
require => Package['telegraf'],
55+
require => Class['telegraf::install'],
5656
}
5757
}
5858
}

0 commit comments

Comments
 (0)