Skip to content

Commit ee611d7

Browse files
authored
Merge pull request #238 from bwilcox/csr_fix
Allow compilers and replicas to merge csr_attributes.
2 parents 7b21708 + 1468f95 commit ee611d7

File tree

5 files changed

+41
-27
lines changed

5 files changed

+41
-27
lines changed

plans/add_compiler.pp

+8-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@
4747
default => ["main:dns_alt_names=${dns_alt_names}"],
4848
}
4949

50+
# Check for and merge csr_attributes.
51+
run_plan('peadm::util::insert_csr_extension_requests', $compiler_target,
52+
extension_requests => {
53+
peadm::oid('pp_auth_role') => 'pe_compiler',
54+
peadm::oid('peadm_availability_group') => $avail_group_letter
55+
}
56+
)
57+
5058
# we first assume that there is no agent installed on the node. If there is, nothing will happen.
5159
run_task('peadm::agent_install', $compiler_target,
5260
server => $primary_target.peadm::certname(),
5361
install_flags => $dns_alt_names_flag + [
5462
'--puppet-service-ensure', 'stopped',
55-
"extension_requests:${peadm::oid('pp_auth_role')}=pe_compiler",
56-
"extension_requests:${peadm::oid('peadm_availability_group')}=${avail_group_letter}",
5763
"main:certname=${compiler_target.peadm::certname()}",
5864
],
5965
)

plans/add_replica.pp

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@
3737
# This has the effect of revoking the node's certificate, if it exists
3838
run_command("puppet infrastructure forget ${replica_target.peadm::certname()}", $primary_target, _catch_errors => true)
3939

40+
# Check for and merge csr_attributes.
41+
run_plan('peadm::util::insert_csr_extension_requests', $replica_target,
42+
extension_requests => {
43+
peadm::oid('peadm_role') => 'puppet/server',
44+
peadm::oid('peadm_availability_group') => $replica_avail_group_letter
45+
}
46+
)
47+
4048
run_task('peadm::agent_install', $replica_target,
4149
server => $primary_target.peadm::certname(),
4250
install_flags => [
4351
'--puppet-service-ensure', 'stopped',
44-
"extension_requests:${peadm::oid('peadm_role')}=puppet/server",
45-
"extension_requests:${peadm::oid('peadm_availability_group')}=${replica_avail_group_letter}",
4652
"main:certname=${replica_target.peadm::certname()}",
4753
"main:dns_alt_names=${dns_alt_names.join(',')}",
4854
],

plans/subplans/install.pp

+25-15
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,30 @@
221221
}
222222
)
223223
},
224+
background('replica-csr.yaml') || {
225+
run_plan('peadm::util::insert_csr_extension_requests', $replica_target,
226+
extension_requests => {
227+
peadm::oid('peadm_role') => 'puppet/server',
228+
peadm::oid('peadm_availability_group') => 'B'
229+
}
230+
)
231+
},
232+
background('compiler-a-csr.yaml') || {
233+
run_plan('peadm::util::insert_csr_extension_requests', $compiler_a_targets,
234+
extension_requests => {
235+
peadm::oid('pp_auth_role') => 'pe_compiler',
236+
peadm::oid('peadm_availability_group') => 'A'
237+
}
238+
)
239+
},
240+
background('compiler-b-csr.yaml') || {
241+
run_plan('peadm::util::insert_csr_extension_requests', $compiler_b_targets,
242+
extension_requests => {
243+
peadm::oid('pp_auth_role') => 'pe_compiler',
244+
peadm::oid('peadm_availability_group') => 'B'
245+
}
246+
)
247+
},
224248
background('primary-postgresql-csr.yaml') || {
225249
run_plan('peadm::util::insert_csr_extension_requests', $primary_postgresql_target,
226250
extension_requests => {
@@ -323,24 +347,10 @@
323347
"main:certname=${target.peadm::certname()}",
324348
]
325349

326-
$role_and_group =
327-
if ($target in $compiler_a_targets) {[
328-
"extension_requests:${peadm::oid('pp_auth_role')}=pe_compiler",
329-
"extension_requests:${peadm::oid('peadm_availability_group')}=A",
330-
]}
331-
elsif ($target in $compiler_b_targets) {[
332-
"extension_requests:${peadm::oid('pp_auth_role')}=pe_compiler",
333-
"extension_requests:${peadm::oid('peadm_availability_group')}=B",
334-
]}
335-
elsif ($target in $replica_target) {[
336-
"extension_requests:${peadm::oid('peadm_role')}=puppet/server",
337-
"extension_requests:${peadm::oid('peadm_availability_group')}=B",
338-
]}
339-
340350
# Get an agent installed and cert signed
341351
run_task('peadm::agent_install', $target,
342352
server => $primary_target.peadm::certname(),
343-
install_flags => $common_install_flags + $role_and_group,
353+
install_flags => $common_install_flags,
344354
)
345355

346356
# Ensure certificate requests have been submitted, then run Puppet

spec/plans/add_compiler_spec.rb

-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ def allow_standard_non_returning_calls
2828
.with_params({ 'server' => 'primary',
2929
'install_flags' => [
3030
'--puppet-service-ensure', 'stopped',
31-
'extension_requests:1.3.6.1.4.1.34380.1.3.13=pe_compiler',
32-
'extension_requests:1.3.6.1.4.1.34380.1.1.9813=A',
3331
'main:certname=compiler'
3432
] })
3533

@@ -53,8 +51,6 @@ def allow_standard_non_returning_calls
5351
'install_flags' => [
5452
'main:dns_alt_names=foo,bar',
5553
'--puppet-service-ensure', 'stopped',
56-
'extension_requests:1.3.6.1.4.1.34380.1.3.13=pe_compiler',
57-
'extension_requests:1.3.6.1.4.1.34380.1.1.9813=A',
5854
'main:certname=compiler'
5955
] })
6056

spec/plans/add_replica_spec.rb

-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ def allow_standard_non_returning_calls
2020
.with_params({ 'server' => 'primary',
2121
'install_flags' => [
2222
'--puppet-service-ensure', 'stopped',
23-
'extension_requests:1.3.6.1.4.1.34380.1.1.9812=puppet/server',
24-
'extension_requests:1.3.6.1.4.1.34380.1.1.9813=B',
2523
'main:certname=replica',
2624
'main:dns_alt_names=replica'
2725
] })
@@ -36,8 +34,6 @@ def allow_standard_non_returning_calls
3634
.with_params({ 'server' => 'primary',
3735
'install_flags' => [
3836
'--puppet-service-ensure', 'stopped',
39-
'extension_requests:1.3.6.1.4.1.34380.1.1.9812=puppet/server',
40-
'extension_requests:1.3.6.1.4.1.34380.1.1.9813=B',
4137
'main:certname=replica',
4238
'main:dns_alt_names=replica,alt'
4339
] })

0 commit comments

Comments
 (0)