4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
# File 'manifests/config.pp', line 4
class dynatraceoneagent::config {
$global_owner = $dynatraceoneagent::global_owner
$global_group = $dynatraceoneagent::global_group
$global_mode = $dynatraceoneagent::global_mode
$service_name = $dynatraceoneagent::service_name
$provider = $dynatraceoneagent::provider
$install_dir = $dynatraceoneagent::install_dir
$created_dir = $dynatraceoneagent::created_dir
$package_state = $dynatraceoneagent::package_state
$service_state = $dynatraceoneagent::service_state
# OneAgent Host Configuration Parameters
$oneagent_tools_dir = $dynatraceoneagent::oneagent_tools_dir
$oactl = $dynatraceoneagent::oneagent_ctl
$oneagent_communication_hash = $dynatraceoneagent::oneagent_communication_hash
$log_monitoring = $dynatraceoneagent::log_monitoring
$log_access = $dynatraceoneagent::log_access
$host_group = $dynatraceoneagent::host_group
$host_tags = $dynatraceoneagent::host_tags
$host_metadata = $dynatraceoneagent::host_metadata
$hostname = $dynatraceoneagent::hostname
$infra_only = $dynatraceoneagent::infra_only
$network_zone = $dynatraceoneagent::network_zone
$oneagent_puppet_conf_dir = $dynatraceoneagent::oneagent_puppet_conf_dir
$oneagent_comms_config_file = $dynatraceoneagent::oneagent_comms_config_file
$oneagent_logmonitoring_config_file = $dynatraceoneagent::oneagent_logmonitoring_config_file
$oneagent_logaccess_config_file = $dynatraceoneagent::oneagent_logaccess_config_file
$hostgroup_config_file = $dynatraceoneagent::hostgroup_config_file
$hostautotag_config_file = $dynatraceoneagent::hostautotag_config_file
$hostmetadata_config_file = $dynatraceoneagent::hostmetadata_config_file
$hostname_config_file = $dynatraceoneagent::hostname_config_file
$oneagent_infraonly_config_file = $dynatraceoneagent::oneagent_infraonly_config_file
$oneagent_networkzone_config_file = $dynatraceoneagent::oneagent_networkzone_config_file
#if ($service_state != 'stopped') {
file { $oneagent_puppet_conf_dir :
ensure => 'directory',
}
$oneagent_set_host_tags_array = $host_tags.map |$value| { "--set-host-tag=${value}" }
$oneagent_set_host_tags_params = join($oneagent_set_host_tags_array, ' ' )
$oneagent_set_host_metadata_array = $host_metadata.map |$value| { "--set-host-property=${value}" }
$oneagent_set_host_metadata_params = join($oneagent_set_host_metadata_array, ' ' )
$oneagent_communication_array = $oneagent_communication_hash.map |$key,$value| { "${key}=${value}" }
$oneagent_communication_params = join($oneagent_communication_array, ' ' )
if ($::kernel == 'Linux') or ($::osfamily == 'AIX') {
$oneagentctl_exec_path = ['/usr/bin/', $oneagent_tools_dir]
$oneagent_remove_host_tags_command = "${oactl} --get-host-tags | xargs -I{} ${oactl} --remove-host-tag={}"
$oneagent_set_host_tags_command = "${oneagent_remove_host_tags_command}; ${oactl} ${oneagent_set_host_tags_params}"
$oneagent_remove_host_metadata_command = "${oactl} --get-host-properties | xargs -I{} ${oactl} --remove-host-property={}"
$oneagent_set_host_metadata_command = "${oneagent_remove_host_metadata_command}; ${oactl} ${oneagent_set_host_metadata_params}"
}
elsif $::osfamily == 'Windows'{
$oneagentctl_exec_path = [$dynatraceoneagent::params::windows_pwsh, $oneagent_tools_dir]
$oneagent_remove_host_tags_command = "powershell ${oactl} --get-host-tags | %{${oactl} --remove-host-tag=\$_}"
$oneagent_set_host_tags_command = "${oneagent_remove_host_tags_command}; ${oactl} ${oneagent_set_host_tags_params}"
$oneagent_remove_host_metadata_command = "powershell ${oactl} --get-host-properties | %{${oactl} --remove-host-property=\$_}"
$oneagent_set_host_metadata_command = "${oneagent_remove_host_metadata_command}; ${oactl} ${oneagent_set_host_metadata_params}"
}
if $oneagent_communication_array.length > 0 {
file { $oneagent_comms_config_file:
ensure => present,
content => String($oneagent_communication_hash),
notify => Exec['set_oneagent_communication'],
mode => $global_mode,
}
} else {
file { $oneagent_comms_config_file:
ensure => absent,
}
}
if $log_monitoring != undef {
file { $oneagent_logmonitoring_config_file:
ensure => present,
content => String($log_monitoring),
notify => Exec['set_log_monitoring'],
mode => $global_mode,
}
} else {
file { $oneagent_logmonitoring_config_file:
ensure => absent,
}
}
if $log_access != undef {
file { $oneagent_logaccess_config_file:
ensure => present,
content => String($log_access),
notify => Exec['set_log_access'],
mode => $global_mode,
}
} else {
file { $oneagent_logaccess_config_file:
ensure => absent,
}
}
if $host_group {
file { $hostgroup_config_file:
ensure => present,
content => $host_group,
notify => Exec['set_host_group'],
mode => $global_mode,
}
} else {
file { $hostgroup_config_file:
ensure => absent,
notify => Exec['unset_host_group'],
}
}
if $host_tags.length > 0 {
file { $hostautotag_config_file:
ensure => present,
content => String($host_tags),
notify => Exec['set_host_tags'],
mode => $global_mode,
}
} else {
file { $hostautotag_config_file:
ensure => absent,
notify => Exec['unset_host_tags'],
}
}
if $host_metadata.length > 0 {
file { $hostmetadata_config_file:
ensure => present,
content => String($host_metadata),
notify => Exec['set_host_metadata'],
mode => $global_mode,
}
} else {
file { $hostmetadata_config_file:
ensure => absent,
notify => Exec['unset_host_metadata'],
}
}
if $hostname {
file { $hostname_config_file:
ensure => present,
content => $hostname,
notify => Exec['set_hostname'],
mode => $global_mode,
}
} else {
file { $hostname_config_file:
ensure => absent,
notify => Exec['unset_hostname'],
}
}
if $infra_only != undef {
file { $oneagent_infraonly_config_file:
ensure => present,
content => String($infra_only),
notify => Exec['set_infra_only'],
mode => $global_mode,
}
} else {
file { $oneagent_infraonly_config_file:
ensure => absent,
}
}
if $network_zone {
file { $oneagent_networkzone_config_file:
ensure => present,
content => $network_zone,
notify => Exec['set_network_zone'],
mode => $global_mode,
}
} else {
file { $oneagent_networkzone_config_file:
ensure => absent,
notify => Exec['unset_network_zone'],
}
}
exec { 'set_oneagent_communication':
command => "${oactl} ${oneagent_communication_params} --restart-service",
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'set_log_monitoring':
command => "${oactl} --set-app-log-content-access=${log_monitoring} --restart-service",
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'set_log_access':
command => "${oactl} --set-system-logs-access-enabled=${log_access} --restart-service",
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'set_host_group':
command => "${oactl} --set-host-group=${host_group} --restart-service",
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'unset_host_group':
command => "${oactl} --set-host-group= --restart-service",
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'set_host_tags':
command => $oneagent_set_host_tags_command,
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'unset_host_tags':
command => $oneagent_remove_host_tags_command,
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'set_host_metadata':
command => $oneagent_set_host_metadata_command,
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'unset_host_metadata':
command => $oneagent_remove_host_metadata_command,
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'set_hostname':
command => "${oactl} --set-host-name=${hostname} --restart-service",
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'unset_hostname':
command => "${oactl} --set-host-name=\"\" --restart-service",
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'set_infra_only':
command => "${oactl} --set-infra-only=${infra_only} --restart-service",
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'set_network_zone':
command => "${oactl} --set-network-zone=${network_zone} --restart-service",
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
exec { 'unset_network_zone':
command => "${oactl} --set-network-zone=\"\" --restart-service",
path => $oneagentctl_exec_path,
cwd => $oneagent_tools_dir,
timeout => 6000,
provider => $provider,
logoutput => on_failure,
refreshonly => true,
}
#}
}
|