eid-ops/global/overlay/etc/puppet/modules/eid/manifests/telegraf2.pp
Patrik Holmqvist 2adc58c274
Try without creating $service_dir explicitly, SC-2522
Error: Cannot alias File[/opt//telegraf] to ["/opt/telegraf"] at (file: /etc/puppet/cosmos-modules/sunet/manifests/misc/create_dir.pp, line: 33); resource ["File", "/opt/telegraf"] already declared (file: /etc/puppet/modules/eid/manifests/telegraf2.pp, line: 21)
2025-03-25 14:54:57 +01:00

55 lines
2 KiB
Puppet

# This puppet manifest is used to configure Telegraf for Sweden Connect
# @param version Version of the docker image to use. (referenced in compose file)
# @param server_fqdn The FQDN of the server. (referenced in compose file)
# @param ports Port mappings for container
# @param service_dir The directory where all related config and files are stored. (referenced in compose file)
class eid::telegraf2 (
String $version = 'latest',
String $server_fqdn = $facts['networking']['fqdn'],
Array $ports = [],
String $service_dir = '/opt/telegraf',
) {
# Get influx values
$influxdb2_token = hiera(influxdb2_token,'NOT_SET_IN_HIERA')
$influx2_token = hiera(influx2_token,'NOT_SET_IN_HIERA')
$influxdb2_org = hiera(influxdb2_org,'NOT_SET_IN_HIERA')
$influxdb2_bucket = hiera(influxdb2_bucket,'NOT_SET_IN_HIERA')
$influxdb2_bucket_proxy = hiera(influxdb2_bucket_proxy,'NOT_SET_IN_HIERA')
file {["${service_dir}/telegraf.conf.d"]: ensure => directory }
concat {"${service_dir}/telegraf.conf":
owner => 'root',
group => 'root',
mode => '0644',
notify => [Sunet::Docker_compose["telegraf"]]
}
# Below not pretty but I'm piggy-backing on this class to add a secondary output to test the new influx2-server
if ($influx2_token != 'NOT_SET_IN_HIERA') {
file { "${service_dir}/telegraf.conf.d/95-telegraf.conf":
ensure => file,
owner => 'root',
group => 'root',
path => "${service_dir}/telegraf.conf.d/95-telegraf.conf",
mode => '0644',
content => template('eid/telegraf2/95-telegraf.conf.erb'),
}
}
eid_glob(["${service_dir}/telegraf.conf.d/*.conf"]).each |String $file| {
concat::fragment { $file:
target => "${service_dir}/telegraf.conf",
source => $file,
}
}
sunet::docker_compose { 'telegraf':
content => template('eid/telegraf2/docker-compose.yml.erb'),
service_name => 'telegraf',
compose_dir => '/opt/',
compose_filename => 'docker-compose.yml',
description => 'telegraf'
}
}