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

Commit c0ee905

Browse files
author
suckatrash
committed
remove puppet_metrics_dashboard::telegraf::* classes
1 parent 3e486f2 commit c0ee905

File tree

10 files changed

+80
-134
lines changed

10 files changed

+80
-134
lines changed

REFERENCE.md

-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
* `puppet_metrics_dashboard::repos`: Configures InfluxDB and Grafana repos
2323
* `puppet_metrics_dashboard::service`: Manages services
2424
* `puppet_metrics_dashboard::telegraf`: Install and configure Telegraf
25-
* `puppet_metrics_dashboard::telegraf::config`: Configures Telegraf
26-
* `puppet_metrics_dashboard::telegraf::install`: Installs Telegraf
27-
* `puppet_metrics_dashboard::telegraf::service`: Manages the Telegraf service
2825

2926
## Defined types
3027

manifests/init.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,6 @@
247247
}
248248

249249
if $_enable_telegraf {
250-
contain puppet_metrics_dashboard::telegraf
250+
include puppet_metrics_dashboard::telegraf
251251
}
252252
}

manifests/telegraf.pp

+74-12
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,81 @@
44
#
55
# @api private
66
class puppet_metrics_dashboard::telegraf {
7-
# Enable Telegraf if `configure_telegraf` is true.
8-
$_enable_telegraf = $puppet_metrics_dashboard::configure_telegraf ? {
9-
true => true,
10-
default => $puppet_metrics_dashboard::enable_telegraf
11-
}
7+
if $puppet_metrics_dashboard::configure_telegraf {
8+
$_puppetdb_metrics = $puppet_metrics_dashboard::puppetdb_metrics
9+
10+
class { 'telegraf':
11+
interval => $puppet_metrics_dashboard::telegraf_agent_interval,
12+
logfile => '/var/log/telegraf/telegraf.log',
13+
hostname => '',
14+
manage_repo => false,
15+
manage_service => false,
16+
outputs => {
17+
'influxdb' => [
18+
{
19+
'urls' => $puppet_metrics_dashboard::influxdb_urls,
20+
'database' => $puppet_metrics_dashboard::telegraf_db_name,
21+
'write_consistency' => 'any',
22+
'timeout' => '5s',
23+
},
24+
],
25+
},
26+
}
27+
28+
file {'/etc/telegraf/telegraf.d/puppet_metrics_dashboard.conf':
29+
ensure => absent,
30+
}
31+
32+
# Transform the host lists into arrays of "hostname:port", using a
33+
# service's default port if no alternate was specified.
34+
$_master_list = $puppet_metrics_dashboard::master_list.map |$entry| {
35+
$entry ? {
36+
Tuple[String, Integer] => { 'host' => $entry[0], 'port' => $entry[1] },
37+
String => { 'host' => $entry, 'port' => 8140 },
38+
}
39+
}
40+
$_puppetdb_list = $puppet_metrics_dashboard::puppetdb_list.map |$entry| {
41+
$entry ? {
42+
Tuple[String, Integer] => { 'host' => $entry[0], 'port' => $entry[1] },
43+
String => { 'host' => $entry, 'port' => 8081 },
44+
}
45+
}
46+
$_postgres_list = $puppet_metrics_dashboard::postgres_host_list.map |$entry| {
47+
$entry ? {
48+
Tuple[String, Integer] => { 'host' => $entry[0], 'port' => $entry[1] },
49+
String => { 'host' => $entry, 'port' => 5432 },
50+
}
51+
}
1252

13-
if $_enable_telegraf {
14-
contain puppet_metrics_dashboard::telegraf::install
15-
contain puppet_metrics_dashboard::telegraf::config
16-
contain puppet_metrics_dashboard::telegraf::service
53+
$_master_list.each |$master| {
54+
puppet_metrics_dashboard::profile::compiler{ $master['host']:
55+
compiler => $master['host'],
56+
port => $master['port'],
57+
timeout => $puppet_metrics_dashboard::http_response_timeout,
58+
interval => $puppet_metrics_dashboard::telegraf_agent_interval,
59+
require => Class['Telegraf'],
60+
}
61+
}
62+
63+
$_puppetdb_list.each |$puppetdb| {
64+
puppet_metrics_dashboard::profile::puppetdb{ $puppetdb['host']:
65+
puppetdb_host => $puppetdb['host'],
66+
port => $puppetdb['port'],
67+
timeout => $puppet_metrics_dashboard::http_response_timeout,
68+
interval => $puppet_metrics_dashboard::telegraf_agent_interval,
69+
require => Class['Telegraf'],
70+
}
71+
}
72+
73+
$_postgres_list.each |$postgres| {
74+
puppet_metrics_dashboard::profile::master::postgres{ $postgres['host']:
75+
postgres_host => $postgres['host'],
76+
port => $postgres['port'],
77+
query_interval => $puppet_metrics_dashboard::pg_query_interval,
78+
require => Class['Telegraf'],
79+
}
80+
}
1781

18-
Class['puppet_metrics_dashboard::telegraf::install']
19-
-> Class['puppet_metrics_dashboard::telegraf::config']
20-
-> Class['puppet_metrics_dashboard::telegraf::service']
2182
}
83+
2284
}

manifests/telegraf/config.pp

-83
This file was deleted.

manifests/telegraf/install.pp

-12
This file was deleted.

manifests/telegraf/service.pp

-14
This file was deleted.

spec/classes/telegraf/config_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper'
22

3-
describe 'puppet_metrics_dashboard::telegraf::config' do
3+
describe 'puppet_metrics_dashboard::telegraf' do
44
on_supported_os(facterversion: '3.7').each do |os, facts|
55
context "with facter 3.7 on #{os}" do
66
let(:node) do

spec/classes/telegraf/install_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper'
22

3-
describe 'puppet_metrics_dashboard::telegraf::install' do
3+
describe 'puppet_metrics_dashboard::telegraf' do
44
on_supported_os(facterversion: '3.7').each do |os, facts|
55
context "with facter 3.7 on #{os}" do
66
let(:node) do

spec/classes/telegraf/service_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper'
22

3-
describe 'puppet_metrics_dashboard::telegraf::service' do
3+
describe 'puppet_metrics_dashboard::telegraf' do
44
on_supported_os(facterversion: '3.7').each do |os, facts|
55
context "with facter 3.7 on #{os}" do
66
let(:node) do

spec/classes/telegraf_spec.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
PRE_COND
1919
end
2020

21-
it { is_expected.to contain_class('puppet_metrics_dashboard::telegraf::install') }
22-
it { is_expected.to contain_class('puppet_metrics_dashboard::telegraf::config') }
23-
it { is_expected.to contain_class('puppet_metrics_dashboard::telegraf::service') }
21+
it { is_expected.to contain_class('puppet_metrics_dashboard::telegraf') }
2422
end
2523

2624
context 'with enable_telegraf and configure_telegraf disabled' do
@@ -33,9 +31,7 @@ class {'puppet_metrics_dashboard':
3331
PRE_COND
3432
end
3533

36-
it { is_expected.not_to contain_class('puppet_metrics_dashboard::telegraf::install') }
37-
it { is_expected.not_to contain_class('puppet_metrics_dashboard::telegraf::config') }
38-
it { is_expected.not_to contain_class('puppet_metrics_dashboard::telegraf::service') }
34+
it { is_expected.not_to contain_class('puppet_metrics_dashboard::telegraf') }
3935
end
4036
end
4137
end

0 commit comments

Comments
 (0)