Skip to content

Commit

Permalink
fix #66 add database mangement for icingadb, add redis base class
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Dec 22, 2022
1 parent e7a8fbb commit 3a4a20f
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
8 changes: 7 additions & 1 deletion examples/mysql/database-mysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
db_pass => 'icinga2',
}

class { '::icinga::db::database':
icingadb_instances => ['192.168.5.13', '192.168.5.23'],
db_type => 'mysql',
db_pass => 'icingadb',
}

class { '::icinga::web::database':
ido_instances => ['192.168.5.13', '192.168.5.23'],
web_instances => ['192.168.5.13', '192.168.5.23'],
db_type => 'mysql',
db_pass => 'icingaweb2',
}
8 changes: 7 additions & 1 deletion examples/pgsql/database-pgsql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
db_pass => 'icinga2',
}

class { '::icinga::db::database':
icingadb_instances => ['192.168.5.13', '192.168.5.23'],
db_type => 'pgsql',
db_pass => 'icingadb',
}

class { '::icinga::web::database':
ido_instances => ['192.168.5.13', '192.168.5.23'],
web_instances => ['192.168.5.13', '192.168.5.23'],
db_type => 'pgsql',
db_pass => 'icingaweb2',
}
50 changes: 50 additions & 0 deletions manifests/db/database.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# @summary
# Setup database for IcingaDB.
#
# @param [Enum['mysql','pgsql']] db_type
# What kind of database type to use.
#
# @param [Array[Stdlib::Host]] icingadb_instances
# List of Hosts to allow write access to the database. Usually an IcingaDB instance.
#
# @param [String] db_pass
# Password to connect the database.
#
# @param [String] db_name
# Name of the database.
#
# @param [String] db_user
# Database user name.
#
class icinga::db::database(
Enum['mysql','pgsql'] $db_type,
Array[Stdlib::Host] $icingadb_instances,
String $db_pass,
String $db_name = 'icingadb',
String $db_user = 'icingadb',
) {

$_db_encoding = $db_type ? {
'mysql' => 'utf8',
default => 'UTF8',
}

::icinga::database { "${db_type}-${db_name}":
db_type => $db_type,
db_name => $db_name,
db_user => $db_user,
db_pass => $db_pass,
access_instances => $icingadb_instances,
mysql_privileges => ['ALL'],
db_encoding => $_db_encoding,
}

if $db_type == 'pgsql' {
postgresql::server::extension { "${db_name}-citext":
extension => 'citext',
database => $db_name,
package_name => 'postgresql-contrib',
}
}
}

13 changes: 13 additions & 0 deletions manifests/redis.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class icinga::redis {
class { 'redis':
manage_repo => false,
manage_package => false,
default_install => false,
ulimit_managed => false,
service_manage => false,
config_owner => 'root',
config_group => 'root',
service_user => 'root',
service_group => 'root',
}
}

0 comments on commit 3a4a20f

Please sign in to comment.