Skip to content

Commit 0de57ad

Browse files
(maint) remove database-validation
With the removal of database-validation from the postgres module: puppetlabs/puppetlabs-postgresql#1484 This module will no longer provide database validation. This removes the validation files from the manifest, spec tests, and parameters.
1 parent a322a7a commit 0de57ad

12 files changed

+7
-265
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Release notes for the puppetlabs-puppetdb module.
77
* Drop support for Ubuntu 16.04 and Scientific Linux 7
88
* Remove all code related to embedded database
99
* Require and install postgres 14 by default
10-
10+
* remove support for database validation due to https://github.com/puppetlabs/puppetlabs-postgresql/pull/1484/
1111

1212
#### 7.14.0 - 2023/10/09
1313
* Owner of puppetdb config.ini is now root

README.md

-12
Original file line numberDiff line numberDiff line change
@@ -434,18 +434,6 @@ storeconfigs backend.
434434
puppet_conf => '/etc/puppet/puppet.conf'
435435
}
436436

437-
**puppetdb::server::validate_db**
438-
439-
Validates that a successful database connection can be established between the
440-
node on which this resource is run and the specified PuppetDB database instance
441-
(host/port/user/password/database name).
442-
443-
puppetdb::server::validate_db { 'validate my puppetdb database connection':
444-
database_host => 'my.postgres.host',
445-
database_username => 'mydbuser',
446-
database_password => 'mydbpassword',
447-
database_name => 'mydbname',
448-
}
449437

450438
### Custom Types
451439

manifests/init.pp

+2-22
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@
101101
# This parameter maps directly to PostgreSQL's `listen_addresses`
102102
# config option. Use a `*` to allow connections on any accessible address.
103103
#
104-
# @param database_validate
105-
# If true, the module will attempt to connect to the database using the specified
106-
# settings and fail if it is not able to do so. Defaults to `true`.
107-
#
108104
# @param node_ttl
109105
# The length of time a node can go without receiving any new data before it's
110106
# automatically deactivated. (defaults to '7d', which is a 7-day period. Set to
@@ -239,11 +235,7 @@
239235
# The text to append to the JDBC connection URI. This should begin with a '?'
240236
# character. For example, to use SSL for the PostgreSQL connection, set this
241237
# parameter's value to `?ssl=true`.
242-
#
243-
# @param read_database_validate
244-
# If true, the module will attempt to connect to the database using the specified
245-
# settings and fail if it is not able to do so. Defaults to `true`.
246-
#
238+
##
247239
# @param read_database_name
248240
# The name of the read database instance to connect to. If `read_database_host`
249241
# is set to `undef`, and `manage_database` is set to `true`, it will use the value of
@@ -413,7 +405,6 @@
413405
$manage_db_password = $puppetdb::params::manage_db_password,
414406
$jdbc_ssl_properties = $puppetdb::params::jdbc_ssl_properties,
415407
$database_listen_address = $puppetdb::params::postgres_listen_addresses,
416-
$database_validate = $puppetdb::params::database_validate,
417408
$node_ttl = $puppetdb::params::node_ttl,
418409
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
419410
$report_ttl = $puppetdb::params::report_ttl,
@@ -437,7 +428,6 @@
437428
$read_database_name = $puppetdb::params::read_database_name,
438429
$manage_read_db_password = $puppetdb::params::manage_read_db_password,
439430
$read_database_jdbc_ssl_properties = $puppetdb::params::read_database_jdbc_ssl_properties,
440-
$read_database_validate = $puppetdb::params::read_database_validate,
441431
$read_log_slow_statements = $puppetdb::params::read_log_slow_statements,
442432
$read_conn_max_age = $puppetdb::params::read_conn_max_age,
443433
$read_conn_keep_alive = $puppetdb::params::read_conn_keep_alive,
@@ -492,7 +482,6 @@
492482
database_name => $database_name,
493483
manage_db_password => $manage_db_password,
494484
jdbc_ssl_properties => $jdbc_ssl_properties,
495-
database_validate => $database_validate,
496485
node_ttl => $node_ttl,
497486
node_purge_ttl => $node_purge_ttl,
498487
report_ttl => $report_ttl,
@@ -518,7 +507,6 @@
518507
read_database_name => $read_database_name,
519508
manage_read_db_password => $manage_read_db_password,
520509
read_database_jdbc_ssl_properties => $read_database_jdbc_ssl_properties,
521-
read_database_validate => $read_database_validate,
522510
read_log_slow_statements => $read_log_slow_statements,
523511
read_conn_max_age => $read_conn_max_age,
524512
read_conn_keep_alive => $read_conn_keep_alive,
@@ -542,14 +530,6 @@
542530
java_bin => $java_bin,
543531
}
544532

545-
$database_before = str2bool($database_validate) ? {
546-
false => Class['puppetdb::server'],
547-
default => [
548-
Class['puppetdb::server'],
549-
Class['puppetdb::server::validate_db']
550-
],
551-
}
552-
553533
class { 'puppetdb::database::postgresql':
554534
listen_addresses => $database_listen_address,
555535
database_name => $database_name,
@@ -568,6 +548,6 @@
568548
read_database_username => $read_database_username,
569549
read_database_password => $read_database_password,
570550
read_database_host => $read_database_host,
571-
before => $database_before,
551+
before => Class['puppetdb::server'],
572552
}
573553
}

manifests/params.pp

-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
$database_password = 'puppetdb'
4040
$manage_db_password = true
4141
$jdbc_ssl_properties = ''
42-
$database_validate = true
4342
$database_max_pool_size = undef
4443
$puppetdb_server = fact('networking.fqdn')
4544

@@ -69,7 +68,6 @@
6968
$read_database_password = 'puppetdb-read'
7069
$manage_read_db_password = true
7170
$read_database_jdbc_ssl_properties = ''
72-
$read_database_validate = true
7371
$read_log_slow_statements = '10'
7472
$read_conn_max_age = '60'
7573
$read_conn_keep_alive = '45'

manifests/server.pp

-11
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@
7272
# character. For example, to use SSL for the PostgreSQL connection, set this
7373
# parameter's value to `?ssl=true`.
7474
#
75-
# @param database_validate
76-
# If true, the module will attempt to connect to the database using the specified
77-
# settings and fail if it is not able to do so. Defaults to `true`.
7875
#
7976
# @param node_ttl
8077
# The length of time a node can go without receiving any new data before it's
@@ -208,10 +205,6 @@
208205
# character. For example, to use SSL for the PostgreSQL connection, set this
209206
# parameter's value to `?ssl=true`.
210207
#
211-
# @param read_database_validate
212-
# If true, the module will attempt to connect to the database using the specified
213-
# settings and fail if it is not able to do so. Defaults to `true`.
214-
#
215208
# @param read_database_name
216209
# The name of the read database instance to connect to. If `read_database_host`
217210
# is set to `undef`, and `manage_database` is set to `true`, it will use the value of
@@ -372,7 +365,6 @@
372365
$database_name = $puppetdb::params::database_name,
373366
$manage_db_password = $puppetdb::params::manage_db_password,
374367
$jdbc_ssl_properties = $puppetdb::params::jdbc_ssl_properties,
375-
$database_validate = $puppetdb::params::database_validate,
376368
$node_ttl = $puppetdb::params::node_ttl,
377369
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
378370
$report_ttl = $puppetdb::params::report_ttl,
@@ -395,7 +387,6 @@
395387
$read_database_name = $puppetdb::params::read_database_name,
396388
$manage_read_db_password = $puppetdb::params::manage_read_db_password,
397389
$read_database_jdbc_ssl_properties = $puppetdb::params::read_database_jdbc_ssl_properties,
398-
$read_database_validate = $puppetdb::params::read_database_validate,
399390
$read_log_slow_statements = $puppetdb::params::read_log_slow_statements,
400391
$read_conn_max_age = $puppetdb::params::read_conn_max_age,
401392
$read_conn_keep_alive = $puppetdb::params::read_conn_keep_alive,
@@ -504,7 +495,6 @@
504495
ssl_ca_cert_path => $ssl_ca_cert_path,
505496
database_max_pool_size => $database_max_pool_size,
506497
jdbc_ssl_properties => $jdbc_ssl_properties,
507-
database_validate => $database_validate,
508498
node_ttl => $node_ttl,
509499
node_purge_ttl => $node_purge_ttl,
510500
report_ttl => $report_ttl,
@@ -544,7 +534,6 @@
544534
ssl_cert_path => $ssl_cert_path,
545535
ssl_ca_cert_path => $ssl_ca_cert_path,
546536
jdbc_ssl_properties => $read_database_jdbc_ssl_properties,
547-
database_validate => $read_database_validate,
548537
log_slow_statements => $read_log_slow_statements,
549538
conn_max_age => $read_conn_max_age,
550539
conn_keep_alive => $read_conn_keep_alive,

manifests/server/database.pp

+1-23
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
$database_name = $puppetdb::params::database_name,
1010
$manage_db_password = $puppetdb::params::manage_db_password,
1111
$jdbc_ssl_properties = $puppetdb::params::jdbc_ssl_properties,
12-
$database_validate = $puppetdb::params::database_validate,
1312
$node_ttl = $puppetdb::params::node_ttl,
1413
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
1514
$report_ttl = $puppetdb::params::report_ttl,
@@ -30,23 +29,6 @@
3029
$ssl_key_pk8_path = $puppetdb::params::ssl_key_pk8_path,
3130
$ssl_ca_cert_path = $puppetdb::params::ssl_ca_cert_path
3231
) inherits puppetdb::params {
33-
if str2bool($database_validate) {
34-
# Validate the database connection. If we can't connect, we want to fail
35-
# and skip the rest of the configuration, so that we don't leave puppetdb
36-
# in a broken state.
37-
#
38-
# NOTE:
39-
# Because of a limitation in the postgres module this will break with
40-
# a duplicate declaration if read and write database host+name are the
41-
# same.
42-
class { 'puppetdb::server::validate_db':
43-
database_host => $database_host,
44-
database_port => $database_port,
45-
database_username => $database_username,
46-
database_password => $database_password,
47-
database_name => $database_name,
48-
}
49-
}
5032

5133
$database_ini = "${confdir}/database.ini"
5234

@@ -58,16 +40,12 @@
5840
}
5941

6042
$file_require = File[$database_ini]
61-
$ini_setting_require = str2bool($database_validate) ? {
62-
false => $file_require,
63-
default => [$file_require, Class['puppetdb::server::validate_db']],
64-
}
6543
# Set the defaults
6644
Ini_setting {
6745
path => $database_ini,
6846
ensure => present,
6947
section => 'database',
70-
require => $ini_setting_require,
48+
require => $file_require ,
7149
}
7250

7351
$classname = 'org.postgresql.Driver'

manifests/server/read_database.pp

+1-24
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
$read_database_name = $puppetdb::params::read_database_name,
1010
$manage_db_password = $puppetdb::params::manage_read_db_password,
1111
$jdbc_ssl_properties = $puppetdb::params::read_database_jdbc_ssl_properties,
12-
$database_validate = $puppetdb::params::read_database_validate,
1312
$log_slow_statements = $puppetdb::params::read_log_slow_statements,
1413
$conn_max_age = $puppetdb::params::read_conn_max_age,
1514
$conn_keep_alive = $puppetdb::params::read_conn_keep_alive,
@@ -24,23 +23,6 @@
2423
$ssl_ca_cert_path = $puppetdb::params::ssl_ca_cert_path
2524
) inherits puppetdb::params {
2625
if $read_database_host != undef {
27-
if str2bool($database_validate) {
28-
# Validate the database connection. If we can't connect, we want to fail
29-
# and skip the rest of the configuration, so that we don't leave puppetdb
30-
# in a broken state.
31-
#
32-
# NOTE:
33-
# Because of a limitation in the postgres module this will break with
34-
# a duplicate declaration if read and write database host+name are the
35-
# same.
36-
class { 'puppetdb::server::validate_read_db':
37-
database_host => $read_database_host,
38-
database_port => $read_database_port,
39-
database_username => $read_database_username,
40-
database_password => $read_database_password,
41-
database_name => $read_database_name,
42-
}
43-
}
4426

4527
$read_database_ini = "${confdir}/read_database.ini"
4628

@@ -51,17 +33,12 @@
5133
mode => '0600',
5234
}
5335

54-
$file_require = File[$read_database_ini]
55-
$ini_setting_require = str2bool($database_validate) ? {
56-
false => $file_require,
57-
default => [$file_require, Class['puppetdb::server::validate_read_db']],
58-
}
5936
# Set the defaults
6037
Ini_setting {
6138
path => $read_database_ini,
6239
ensure => present,
6340
section => 'read-database',
64-
require => $ini_setting_require,
41+
require => File[$read_database_ini],
6542
}
6643

6744
$classname = 'org.postgresql.Driver'

manifests/server/validate_db.pp

-21
This file was deleted.

manifests/server/validate_read_db.pp

-21
This file was deleted.

spec/defines/database/postgresql_ssl_rules_spec.rb

+2-26
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,13 @@
66
'puppetdb-read': {
77
database_name: 'puppetdb',
88
database_username: 'monitor',
9-
postgres_version: '11',
9+
postgres_version: '14',
1010
puppetdb_server: 'localhost',
1111
},
1212
'monitor': {
1313
database_name: 'opensesame',
1414
database_username: 'grover',
15-
postgres_version: '11',
16-
puppetdb_server: 'rainbow',
17-
},
18-
}
19-
20-
valid_12plus = {
21-
'puppetdb-read': {
22-
database_name: 'puppetdb',
23-
database_username: 'monitor',
24-
postgres_version: '12',
25-
puppetdb_server: 'localhost',
26-
},
27-
'monitor': {
28-
database_name: 'opensesame',
29-
database_username: 'grover',
30-
postgres_version: '12',
15+
postgres_version: '14',
3116
puppetdb_server: 'rainbow',
3217
},
3318
}
@@ -51,15 +36,6 @@
5136
end
5237
end
5338

54-
valid_12plus.each do |name, params|
55-
context "for valid_12plus #{name}" do
56-
include_examples 'puppetdb::database::postgresql_ssl_rules' do
57-
let(:title) { name.to_s }
58-
let(:params) { params }
59-
end
60-
end
61-
end
62-
6339
invalid.each do |name, params|
6440
context "for invalid #{name}" do
6541
include_examples 'puppetdb::database::postgresql_ssl_rules', Puppet::Error do

0 commit comments

Comments
 (0)