-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #302 debian dbconfig for mysql and pgsql, add class debian::dbconfig
- Loading branch information
Showing
4 changed files
with
113 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
include ::postgresql::server | ||
|
||
postgresql::server::db { 'icinga2': | ||
user => 'icinga2', | ||
password => postgresql_password('icinga2', 'supersecret'), | ||
} | ||
|
||
class{ 'icinga2': | ||
manage_repo => true, | ||
} | ||
|
||
class{ 'icinga2::feature::idopgsql': | ||
host => "127.0.0.1", | ||
user => "icinga2", | ||
password => "icinga2", | ||
database => "icinga2", | ||
import_schema => true | ||
host => "127.0.0.1", | ||
user => "icinga2", | ||
password => "supersecret", | ||
database => "icinga2", | ||
import_schema => true, | ||
require => Postgresql::Server::Db['icinga2'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
class icinga2::debian::dbconfig( | ||
$dbtype, | ||
$dbserver, | ||
$dbport, | ||
$dbname, | ||
$dbuser, | ||
$dbpass, | ||
$ssl = false, | ||
) { | ||
|
||
if defined($caller_module_name) and $module_name != $caller_module_name and $caller_module_name != '' { | ||
fail("icinga2::debian::dbconfig is a private define resource of the module icinga2, you're not permitted to use it.") | ||
} | ||
|
||
validate_re($dbtype, [ '^mysql$', '^pgsql$' ], | ||
"${dbtype} isn't supported. Valid values are 'mysql' and 'pgsql'.") | ||
validate_string($dbserver) | ||
validate_integer($dbport) | ||
validate_string($dbname) | ||
validate_string($dbuser) | ||
validate_string($dbpass) | ||
validate_bool($ssl) | ||
|
||
# dbconfig config for Debian or Ubuntu | ||
if $::osfamily == 'debian' { | ||
|
||
include ::icinga2::params | ||
|
||
case $dbtype { | ||
'mysql': { | ||
$default_port = 3306 | ||
$path = "/etc/dbconfig-common/${::icinga2::params::ido_mysql_package}.conf" | ||
} | ||
'pgsql': { | ||
$default_port = 5432 | ||
$path = "/etc/dbconfig-common/${::icinga2::params::ido_pgsql_package}.conf" | ||
} | ||
} | ||
|
||
file_line { "dbc-${dbtype}-dbuser": | ||
path => $path, | ||
line => "dbc_dbuser='${dbuser}'", | ||
match => '^dbc_dbuser\s*=', | ||
} | ||
file_line { "dbc-${dbtype}-dbpass": | ||
path => $path, | ||
line => "dbc_dbpass='${dbpass}'", | ||
match => '^dbc_dbpass\s*=', | ||
} | ||
file_line { "dbc-${dbtype}-dbname": | ||
path => $path, | ||
line => "dbc_dbname='${dbname}'", | ||
match => '^dbc_dbname\s*=', | ||
} | ||
# only set host if isn't the default | ||
if $dbserver != '127.0.0.1' and $dbserver != 'localhost' { | ||
file_line { "dbc-${dbtype}-dbserver": | ||
path => $path, | ||
line => "dbc_dbserver='${dbserver}'", | ||
match => '^dbc_dbserver\s*=', | ||
} | ||
} | ||
# only set port if isn't the default | ||
if $dbport != $default_port { | ||
file_line { "dbc-${dbtype}-dbport": | ||
path => $path, | ||
line => "dbc_dbport='${dbport}'", | ||
match => '^dbc_dbport\s*=', | ||
} | ||
} | ||
# set ssl | ||
if $ssl { | ||
file_line { "dbc-${dbtype}-ssl": | ||
path => $path, | ||
line => "dbc_ssl='true'", | ||
match => '^dbc_ssl\s*=', | ||
} | ||
} | ||
|
||
} # debian dbconfig | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters