Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tablespace parameter #649

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions manifests/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
# The default collation of the database.
# default: utf8_general_ci
#
# [* database_tablespace*]
# The tablespace the database will be created in. This setting only
# affects PostgreSQL databases.
# === Example
#
# When running everything on a single node, please check
Expand Down Expand Up @@ -129,20 +132,27 @@
$database_host_ip = $zabbix::params::server_database_host_ip,
$database_charset = $zabbix::params::server_database_charset,
$database_collate = $zabbix::params::server_database_collate,
Optional[String[1]] $database_tablespace = $zabbix::params::server_database_tablespace,
) inherits zabbix::params {

# So lets create the databases and load all files. This can only be
# happen when manage_database is set to true (Default).
if $manage_database == true {
# Complain if database_tablespace is set and the database_type is not postgresql
if ($database_tablespace and $database_type != 'postgresql') {
fail("database_tablespace is set to '${database_tablespace}'. This setting is only useful for PostgreSQL databases.")
}

case $database_type {
'postgresql': {
# This is the PostgreSQL part.
# Create the postgres database.
postgresql::server::db { $database_name:
user => $database_user,
owner => $database_user,
password => postgresql_password($database_user, $database_password),
require => Class['postgresql::server'],
user => $database_user,
owner => $database_user,
password => postgresql_password($database_user, $database_password),
require => Class['postgresql::server'],
tablespace => $database_tablespace,
}

# When database not in some server with zabbix server include pg_hba_rule to server
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
$server_database_schema = undef
$server_database_socket = undef
$server_database_user = 'zabbix_server'
$server_database_tablespace = undef
$server_debuglevel = '3'
$server_externalscripts = '/usr/lib/zabbix/externalscripts'
$server_historycachesize = '8M'
Expand Down
27 changes: 27 additions & 0 deletions spec/classes/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,33 @@ class { 'mysql::client':
it { is_expected.to contain_class('zabbix::params') }
end

describe 'database_type is postgresql, tablespace is not explicitly set' do
let :params do
{
database_type: 'postgresql',
database_name: 'zabbix-server',
database_user: 'zabbix-server',
zabbix_type: 'server'
}
end

it { is_expected.to contain_postgresql__server__db('zabbix-server').with_tablespace(nil) }
end

describe 'database_type is postgresql, tablespace is explicitly set' do
let :params do
{
database_type: 'postgresql',
database_name: 'zabbix-server',
database_user: 'zabbix-server',
zabbix_type: 'server',
database_tablespace: 'zabbix'
}
end

it { is_expected.to contain_postgresql__server__db('zabbix-server').with_tablespace('zabbix') }
end

describe 'database_type is mysql, zabbix_type is server and is multiple host setup' do
let :params do
{
Expand Down