Skip to content

Commit d0af170

Browse files
author
DEFERME Bert
committed
Import timescaledb sql file based on boolean
1 parent f4796f1 commit d0af170

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

manifests/database/postgresql.pp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# @param database_host Hostname to use to connect to the database
1010
# @param database_port Database port to be used for the import process.
1111
# @param database_path Path to the database executable
12+
# @param manage_timescale Import the timescaledb sql file?
1213
# @author Werner Dijkerman <[email protected]>
1314
class zabbix::database::postgresql (
1415
$zabbix_type = '',
@@ -20,6 +21,7 @@
2021
$database_host = '',
2122
Optional[Stdlib::Port::Unprivileged] $database_port = undef,
2223
$database_path = $zabbix::params::database_path,
24+
Boolean $manage_timescale = false,
2325
) inherits zabbix::params {
2426
assert_private()
2527

@@ -110,6 +112,27 @@
110112
provider => 'shell',
111113
require => Exec['update_pgpass'],
112114
}
115+
if $manage_timescale {
116+
# Enable timescaledb
117+
$_timescaledb_sql = [
118+
"cd ${schema_path}",
119+
"&& psql -h '${database_host}'",
120+
"-U '${database_user}'",
121+
"-d '${database_name}'",
122+
'-f timescaledb.sql',
123+
'&& touch /etc/zabbix/.timescaledb.done',
124+
]
125+
exec { 'zabbix_timescaledb.sql':
126+
command => $_timescaledb_sql.join(' '),
127+
path => "/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:${database_path}",
128+
unless => 'test -f /etc/zabbix/.timescaledb.done',
129+
provider => 'shell',
130+
require => [
131+
Exec['update_pgpass'],
132+
Exec['zabbix_server_data.sql'],
133+
],
134+
}
135+
}
113136
}
114137
default: {
115138
fail 'We do not work.'

0 commit comments

Comments
 (0)