Skip to content

Commit 9d1791e

Browse files
author
DEFERME Bert
committed
Import timescaledb sql file based on boolean
1 parent 7a0bed1 commit 9d1791e

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
Stdlib::Port::Unprivileged $database_port = 5432,
2223
$database_path = $zabbix::params::database_path,
24+
Boolean $manage_timescale = false,
2325
) inherits zabbix::params {
2426
assert_private()
2527

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

0 commit comments

Comments
 (0)