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
|
# File 'manifests/init.pp', line 14
class influxdb (
String $hostname,
String $datadir,
String $aws_access_key_id,
String $aws_secret_access_key,
String $email,
String $container_ip = '172.17.0.2',
Optional[String] $backup_target = undef,
Optional[String] $backup_watchdog = undef,
Optional[String] $backup_password = undef,
Optional[Hash[String, String]] $backup_environment = undef,
Optional[String] $backup_rclone = undef,
) {
$hook_script = "#!/usr/bin/env bash
cp \$LEGO_CERT_PATH ${datadir}/certs/cert
cp \$LEGO_CERT_KEY_PATH ${datadir}/certs/key
chown root:1000 ${datadir}/certs/cert ${datadir}/certs/key
chmod 0640 ${datadir}/certs/cert ${datadir}/certs/key
/usr/bin/systemctl restart container@influxdb"
file { [$datadir, "${datadir}/data", "${datadir}/certs"]:
ensure => directory,
}
-> file { "${datadir}/config.yml":
ensure => file,
content => template('influxdb/config.yml.erb'),
}
-> acme::certificate { $hostname:
hook_script => $hook_script,
aws_access_key_id => $aws_access_key_id,
aws_secret_access_key => $aws_secret_access_key,
email => $email,
}
-> firewall { '100 dnat for influxdb':
chain => 'DOCKER_EXPOSE',
jump => 'DNAT',
proto => 'tcp',
dport => 443,
todest => "${container_ip}:8086",
table => 'nat',
}
-> docker::container { 'influxdb':
image => 'influxdb:latest',
args => [
"--ip ${container_ip}",
"-v ${datadir}/data:/var/lib/influxdb2",
"-v ${datadir}/config.yml:/etc/influxdb2/config.yml",
"-v ${datadir}/certs:/mnt/certs",
],
cmd => '',
}
if $backup_target != undef {
backup::repo { 'influxdb':
source => "${datadir}/data",
target => $backup_target,
watchdog_url => $backup_watchdog,
password => $backup_password,
environment => $backup_environment,
rclone_config => $backup_rclone,
}
}
}
|