-
Notifications
You must be signed in to change notification settings - Fork 233
Make database validation optional #157
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| $database_password = $puppetdb::params::read_database_password, | ||
| $database_name = $puppetdb::params::read_database_name, | ||
| $database_ssl = $puppetdb::params::read_database_ssl, | ||
| $database_validate = $puppetdb::params::read_database_validate, | ||
| $log_slow_statements = $puppetdb::params::read_log_slow_statements, | ||
| $conn_max_age = $puppetdb::params::read_conn_max_age, | ||
| $conn_keep_alive = $puppetdb::params::read_conn_keep_alive, | ||
|
|
@@ -18,21 +19,23 @@ | |
|
|
||
| # Only add the read database configuration if database host is defined. | ||
| if $database_host != undef { | ||
| # Validate the database connection. If we can't connect, we want to fail | ||
| # and skip the rest of the configuration, so that we don't leave puppetdb | ||
| # in a broken state. | ||
| # | ||
| # NOTE: | ||
| # Because of a limitation in the postgres module this will break with | ||
| # a duplicate declaration if read and write database host+name are the | ||
| # same. | ||
| class { 'puppetdb::server::validate_read_db': | ||
| database => $database, | ||
| database_host => $database_host, | ||
| database_port => $database_port, | ||
| database_username => $database_username, | ||
| database_password => $database_password, | ||
| database_name => $database_name, | ||
| if str2bool($database_validate) { | ||
| # Validate the database connection. If we can't connect, we want to fail | ||
| # and skip the rest of the configuration, so that we don't leave puppetdb | ||
| # in a broken state. | ||
| # | ||
| # NOTE: | ||
| # Because of a limitation in the postgres module this will break with | ||
| # a duplicate declaration if read and write database host+name are the | ||
| # same. | ||
| class { 'puppetdb::server::validate_read_db': | ||
| database => $database, | ||
| database_host => $database_host, | ||
| database_port => $database_port, | ||
| database_username => $database_username, | ||
| database_password => $database_password, | ||
| database_name => $database_name, | ||
| } | ||
| } | ||
|
|
||
| file { "${confdir}/read_database.ini": | ||
|
|
@@ -42,12 +45,16 @@ | |
| mode => '0600'; | ||
| } | ||
|
|
||
| $ini_setting_require = str2bool($database_validate) ? { | ||
| false => undef, | ||
| default => Class['puppetdb::server::validate_read_db'], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we're replacing this with puppetdb::server::validate_read_db -- was that an existing bug or is this changing behavior? ping @kbarber
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a change of behaviour. By all means switch to validate_read_db as necessary. My only requirement is that I can disable validation so we can build AWS AMIs without requiring a postgresql connection.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the top of my head I think the change to validate_read_db is correct IMHO. If it works, I would keep it and call the old way a bug. In theory, it shouldn't fundamentally change how this works, at least I don't believe so. Users shouldn't notice unless they were hitting an ordering bug, I presume. |
||
| } | ||
| # Set the defaults | ||
| Ini_setting { | ||
| path => "${confdir}/read_database.ini", | ||
| ensure => present, | ||
| section => 'read-database', | ||
| require => Class['puppetdb::server::validate_db'], | ||
| require => $ini_setting_require, | ||
| } | ||
|
|
||
| if $database == 'postgres' { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could avoid this entirely by setting the class's (
puppetdb::server::validate_db) before param toIni_setting <| |>; collecting on allIni_setting's :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not worth doing it this time around, but worth thinking about later. If we ever get around to implementing a defined resource to wrap these ini settings or something, probably better to do it using that resource instead of inifile, since inifile could bleed into other modules and create more edges than necessary in the graph. Extraneous edges == bad sometimes, because it makes for a larger catalog.