forked from SumoLogic/sumologic-otel-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.pp
66 lines (55 loc) · 2.03 KB
/
init.pp
1
2
3
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
class install_otel_collector {
$otel_collector_version = "0.0.52-beta.0" # version of Sumo Logic Distro of OpenTelemetry Collector
$systemd_service = false # enables creation of Systemd Service for Sumo Logic Distro of OpenTelemetry Collector
$arch = $facts['os']['architecture'] ? {
'aarch64' => 'arm64',
'arm64' => 'arm64',
default => 'amd64',
}
$os_family = $facts['os']['family'] ? {
'Darwin' => 'darwin',
default => 'linux',
}
exec {"download the release binary":
cwd => "/usr/local/bin/",
command => "curl -sLo otelcol-sumo https://github.com/SumoLogic/sumologic-otel-collector/releases/download/v${otel_collector_version}/otelcol-sumo-${otel_collector_version}-${os_family}_${arch}",
path => ['/usr/local/bin/', '/usr/bin', '/usr/sbin', '/bin'],
}
exec {"make otelcol-sumo executable":
cwd => "/usr/local/bin/",
command => "chmod +x otelcol-sumo",
path => ['/usr/local/bin/', '/usr/bin', '/usr/sbin', '/bin'],
}
file {"/etc/otelcol-sumo":
ensure => 'directory',
}
file {"/etc/otelcol-sumo/config.yaml":
source => "puppet:///modules/install_otel_collector/config.yaml",
mode => "640",
}
group {"opentelemetry":
ensure => "present",
}
user {"opentelemetry":
ensure => "present",
groups => ["opentelemetry"],
managehome => true,
}
if $systemd_service {
file {"/etc/systemd/system/otelcol-sumo.service":
source => "puppet:///modules/install_otel_collector/systemd_service",
mode => "644",
}
service {"otelcol-sumo":
ensure => "running",
enable => true,
}
} else {
exec { 'run otelcol-sumo in background':
command => 'sudo -u opentelemetry /usr/local/bin/otelcol-sumo --config /etc/otelcol-sumo/config.yaml > /var/log/otelcol.log 2>&1 &',
path => ['/usr/local/bin/', '/usr/bin', '/usr/sbin', '/bin'],
logoutput => true,
provider => shell,
}
}
}