36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
|
# File 'manifests/init.pp', line 36
class puppet_operational_dashboards (
Boolean $manage_influxdb = true,
String $influxdb_host = lookup(influxdb::host, undef, undef, $facts['networking']['fqdn']),
Integer $influxdb_port = lookup(influxdb::port, undef, undef, 8086),
String $initial_org = lookup(influxdb::initial_org, undef, undef, 'puppetlabs'),
String $initial_bucket = lookup(influxdb::initial_bucket, undef, undef, 'puppet_data'),
Optional[Sensitive[String]] $influxdb_token = lookup(influxdb::token, undef, undef, undef),
Optional[Sensitive[String]] $telegraf_token = undef,
String $telegraf_token_name = 'puppet telegraf token',
String $influxdb_token_file = lookup(influxdb::token_file, undef, undef, $facts['identity']['user'] ? {
'root' => '/root/.influxdb_token',
default => "/home/${facts['identity']['user']}/.influxdb_token"
}),
Boolean $manage_telegraf = true,
Boolean $manage_telegraf_token = true,
Boolean $use_ssl = true,
) {
unless $facts['os']['family'] in ['RedHat', 'Debian', 'Suse'] {
fail("Installation on ${facts['os']['family']} is not supported")
}
if $manage_influxdb {
class { 'influxdb':
host => $influxdb_host,
port => $influxdb_port,
use_ssl => $use_ssl,
initial_org => $initial_org,
token_file => $influxdb_token_file,
}
influxdb_org { $initial_org:
ensure => present,
use_ssl => $use_ssl,
token => $influxdb_token,
require => Class['influxdb'],
token_file => $influxdb_token_file,
}
influxdb_bucket { $initial_bucket:
ensure => present,
use_ssl => $use_ssl,
org => $initial_org,
token => $influxdb_token,
require => [Class['influxdb'], Influxdb_org[$initial_org]],
token_file => $influxdb_token_file,
}
Influxdb_auth {
require => Class['influxdb'],
}
}
if $manage_telegraf_token {
# Create a token with permissions to read and write timeseries data
# The influxdb::retrieve_token() function cannot find a token during the catalog compilation which creates it
# i.e. it takes two agent runs to become available
influxdb_auth { $telegraf_token_name:
ensure => present,
use_ssl => $use_ssl,
org => $initial_org,
token => $influxdb_token,
token_file => $influxdb_token_file,
permissions => [
{
'action' => 'read',
'resource' => {
'type' => 'telegrafs',
}
},
{
'action' => 'write',
'resource' => {
'type' => 'telegrafs',
}
},
{
'action' => 'read',
'resource' => {
'type' => 'buckets',
}
},
{
'action' => 'write',
'resource' => {
'type' => 'buckets',
}
},
],
}
}
if $manage_telegraf {
include 'puppet_operational_dashboards::telegraf::agent'
}
include 'puppet_operational_dashboards::profile::dashboards'
}
|