Skip to content

Commit 97aaead

Browse files
Filipovici-Andreiaustb
authored andcommitted
(maint) Update documentation with how to use SSL connections
And fix the puppetdb_host in the pg_ident rule.
1 parent 26a653f commit 97aaead

File tree

7 files changed

+87
-2
lines changed

7 files changed

+87
-2
lines changed

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ your manifest will look like:
8585
node <hostname> {
8686
# Configure puppetdb and its underlying database
8787
class { 'puppetdb': }
88+
8889
# Configure the Puppet master to use puppetdb
8990
class { 'puppetdb::master::config': }
9091
}
@@ -133,6 +134,55 @@ This should be all it takes to get a 3-node, distributed installation of
133134
PuppetDB up and running. Note that, if you prefer, you could easily move two of
134135
these classes to a single node and end up with a 2-node setup instead.
135136

137+
### Enable SSL connections
138+
139+
To use SSL connections for the single node setup, use the following manifest:
140+
141+
node <hostname> {
142+
# Here we configure puppetdb and PostgreSQL to use ssl connections
143+
class { 'puppetdb':
144+
postgresql_ssl_on => true,
145+
database_host => '<hostname>',
146+
database_listen_address => '0.0.0.0'
147+
}
148+
149+
# Configure the Puppet master to use puppetdb
150+
class { 'puppetdb::master::config': }
151+
152+
To use SSL connections for the multiple nodes setup, use the following manifest:
153+
154+
$puppetdb_host = 'puppetdb.example.lan'
155+
$postgres_host = 'postgres.example.lan'
156+
157+
node 'master.example.lan' {
158+
# Here we configure the Puppet master to use PuppetDB,
159+
# telling it the hostname of the PuppetDB node.
160+
class { 'puppetdb::master::config':
161+
puppetdb_server => $puppetdb_host,
162+
}
163+
}
164+
165+
node 'postgres.example.lan' {
166+
# Here we install and configure PostgreSQL and the PuppetDB
167+
# database instance, and tell PostgreSQL that it should
168+
# listen for connections to the `$postgres_host`.
169+
# We also enable SSL connections.
170+
class { 'puppetdb::database::postgresql':
171+
listen_addresses => $postgres_host,
172+
postgresql_ssl_on => true,
173+
puppetdb_server => $puppetdb_host
174+
}
175+
}
176+
177+
node 'puppetdb.example.lan' {
178+
# Here we install and configure PuppetDB, and tell it where to
179+
# find the PostgreSQL database. We also enable SSL connections.
180+
class { 'puppetdb::server':
181+
database_host => $postgres_host,
182+
postgresql_ssl_on => true
183+
}
184+
}
185+
136186
### Beginning with PuppetDB
137187

138188
Whether you choose a single node development setup or a multi-node setup, a
@@ -360,6 +410,11 @@ If true, open the `ssl_listen_port` on the firewall. Defaults to `undef`.
360410

361411
Specify the supported SSL protocols for PuppetDB (e.g. TLSv1, TLSv1.1, TLSv1.2.)
362412

413+
### `postgresql_ssl_on`
414+
415+
If `true`, it configures SSL connections between PuppetDB and the PostgreSQL database.
416+
Defaults to `false`.
417+
363418
#### `cipher_suites`
364419

365420
Configure jetty's supported `cipher-suites` (e.g. `SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384`).

manifests/database/postgresql.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# information.
33
class puppetdb::database::postgresql(
44
$listen_addresses = $puppetdb::params::database_host,
5+
$puppetdb_server = $puppetdb::params::puppetdb_server,
56
$database_name = $puppetdb::params::database_name,
67
$database_username = $puppetdb::params::database_username,
78
$database_password = $puppetdb::params::database_password,
@@ -34,6 +35,7 @@
3435
class { 'puppetdb::database::ssl_configuration':
3536
database_name => $database_name,
3637
database_username => $database_username,
38+
puppetdb_server => $puppetdb_server,
3739
postgresql_ssl_key_path => $postgresql_ssl_key_path,
3840
postgresql_ssl_cert_path => $postgresql_ssl_cert_path,
3941
postgresql_ssl_ca_cert_path => $postgresql_ssl_ca_cert_path

manifests/database/ssl_configuration.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
class puppetdb::database::ssl_configuration(
44
$database_name = $puppetdb::params::database_name,
55
$database_username = $puppetdb::params::database_username,
6+
$puppetdb_server = $puppetdb::params::puppetdb_server,
67
$postgresql_ssl_key_path = $puppetdb::params::postgresql_ssl_key_path,
78
$postgresql_ssl_cert_path = $puppetdb::params::postgresql_ssl_cert_path,
89
$postgresql_ssl_ca_cert_path = $puppetdb::params::postgresql_ssl_ca_cert_path
@@ -74,7 +75,7 @@
7475

7576
postgresql::server::pg_ident_rule {"Map the SSL certificate of the server as a ${database_username} user":
7677
map_name => $identity_map_key,
77-
system_username => $::fqdn,
78+
system_username => $puppetdb_server,
7879
database_username => $database_username,
7980
}
8081
}

manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
$puppetdb_service_status = $puppetdb::params::puppetdb_service_status,
5858
$puppetdb_user = $puppetdb::params::puppetdb_user,
5959
$puppetdb_group = $puppetdb::params::puppetdb_group,
60+
$puppetdb_server = $puppetdb::params::puppetdb_server,
6061
$read_database = $puppetdb::params::read_database,
6162
$read_database_host = $puppetdb::params::read_database_host,
6263
$read_database_port = $puppetdb::params::read_database_port,
@@ -184,6 +185,7 @@
184185
class { '::puppetdb::database::postgresql':
185186
listen_addresses => $database_listen_address,
186187
database_name => $database_name,
188+
puppetdb_server => $puppetdb_server,
187189
database_username => $database_username,
188190
database_password => $database_password,
189191
database_port => $database_port,

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
$jdbc_ssl_properties = ''
3737
$database_validate = true
3838
$database_max_pool_size = undef
39+
$puppetdb_server = $::fqdn
3940

4041
# These settings manage the various auto-deactivation and auto-purge settings
4142
$node_ttl = '7d'

spec/unit/classes/database/ssl_configuration_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,22 @@
118118
.with_system_username(facts[:fqdn])
119119
.with_database_username(params[:database_name])
120120
end
121+
122+
context 'when the puppetdb_server is set' do
123+
let(:params) do
124+
{
125+
puppetdb_server: 'puppetdb_fqdn',
126+
database_name: 'puppetdb',
127+
database_username: 'puppetdb',
128+
}
129+
end
130+
131+
it 'has ident rule with the specified puppetdb_server host' do
132+
is_expected.to contain_postgresql__server__pg_ident_rule("Map the SSL certificate of the server as a #{params[:database_username]} user")
133+
.with_map_name(identity_map)
134+
.with_system_username(params[:puppetdb_server])
135+
.with_database_username(params[:database_name])
136+
end
137+
end
121138
end
122139
end

spec/unit/classes/init_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,18 @@ class { 'postgresql::server':
7171
let(:params) do
7272
{
7373
postgresql_ssl_on: true,
74+
puppetdb_server: 'puppetdb_host',
7475
}
7576
end
7677

7778
it { is_expected.to contain_class('puppetdb::server').with('postgresql_ssl_on' => true) }
78-
it { is_expected.to contain_class('puppetdb::database::postgresql').with('postgresql_ssl_on' => true) }
79+
it {
80+
is_expected.to contain_class('puppetdb::database::postgresql')
81+
.with(
82+
'postgresql_ssl_on' => true,
83+
'puppetdb_server' => 'puppetdb_host',
84+
)
85+
}
7986
end
8087
end
8188
end

0 commit comments

Comments
 (0)