Skip to content

Commit c8d956b

Browse files
committed
Set allow list rules on replica PuppetDB
When adding a compiler using the add_compiler plan and a replica is provisioned, it is necessary to add the new compiler's certificate name to the PuppetDB instance that will serve as replica for the compiler.
1 parent 33317df commit c8d956b

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

plans/add_compiler.pp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,35 @@
1414
Peadm::SingleTargetSpec $compiler_host,
1515
Peadm::SingleTargetSpec $primary_host,
1616
Peadm::SingleTargetSpec $primary_postgresql_host,
17-
){
17+
) {
1818
$compiler_target = peadm::get_targets($compiler_host, 1)
1919
$primary_target = peadm::get_targets($primary_host, 1)
2020
$primary_postgresql_target = peadm::get_targets($primary_postgresql_host, 1)
2121

22+
# Get current peadm config to determine where to setup additional rules for
23+
# compiler's secondary PuppetDB instances
24+
$peadm_config = run_task('peadm::get_peadm_config', $primary_target).first.value
25+
26+
# Return the opposite server than the compiler to be added so it can be
27+
# configured with the appropriate rules for Puppet Server access from
28+
# compiler
29+
$replica_avail_group_letter = $avail_group_letter ? { 'A' => 'B', 'B' => 'A' }
30+
$replica_puppetdb = $peadm_config['role-letter']['server'][$replica_avail_group_letter]
31+
32+
$replica_puppetdb_target = peadm::get_targets($replica_puppetdb, 1)
33+
2234
# Stop puppet.service
23-
run_command('systemctl stop puppet.service', $primary_postgresql_target)
35+
run_command('systemctl stop puppet.service', peadm::flatten_compact([
36+
$primary_postgresql_target,
37+
$replica_puppetdb_target
38+
]))
39+
40+
apply($replica_puppetdb_target) {
41+
file_line { 'pe-puppetdb-compiler-cert-allow':
42+
path => '/etc/puppetlabs/puppetdb/certificate-allowlist',
43+
line => $compiler_target.peadm::certname(),
44+
}
45+
}
2446

2547
# Add the following two lines to /opt/puppetlabs/server/data/postgresql/11/data/pg_ident.conf
2648
#
@@ -89,11 +111,15 @@
89111
run_task('peadm::puppet_runonce', $compiler_target)
90112

91113
# On <primary_postgresql_host> run the puppet agent
92-
run_task('peadm::puppet_runonce', $primary_postgresql_target)
114+
run_task('peadm::puppet_runonce', peadm::flatten_compact([
115+
$primary_postgresql_target,
116+
$replica_puppetdb_target
117+
]))
93118

94119
# On <primary_postgresql_host> start puppet.service
95120
run_command('systemctl start puppet.service', peadm::flatten_compact([
96121
$primary_postgresql_target,
122+
$replica_puppetdb_target,
97123
$compiler_target,
98124
]))
99125

0 commit comments

Comments
 (0)