Skip to content

Commit c7654e6

Browse files
Merge pull request #5 from benjamin-robertson/devmain
Bump to version 1.0.0
2 parents 8c4178b + c3065b1 commit c7654e6

8 files changed

+79
-38
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## Release 1.0.0
6+
7+
**Features**
8+
9+
- Added support for older Puppet enterprise versions which still use 'master' instead of 'primary server'. (must set the support_legacy_pe parameter to true to enable this support)
10+
11+
**Bugfixes**
12+
13+
- Added exception handling for reading existing csr_attributes.yaml. Corrupted yaml caused the plan to fail for that node. Csr_attributes data is now ignored if its invalid.
14+
515
## Release 0.2.0
616

717
**Features**

Gemfile.lock

+24-26
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ GEM
22
remote: https://rubygems.org/
33
specs:
44
CFPropertyList (2.3.6)
5-
addressable (2.8.1)
5+
addressable (2.8.4)
66
public_suffix (>= 2.0.2, < 6.0)
77
ansi (1.5.0)
88
ast (2.4.2)
99
awesome_print (1.9.2)
1010
aws-eventstream (1.2.0)
11-
aws-partitions (1.700.0)
12-
aws-sdk-core (3.170.0)
11+
aws-partitions (1.748.0)
12+
aws-sdk-core (3.171.0)
1313
aws-eventstream (~> 1, >= 1.0.2)
1414
aws-partitions (~> 1, >= 1.651.0)
1515
aws-sigv4 (~> 1.5)
1616
jmespath (~> 1, >= 1.6.1)
17-
aws-sdk-ec2 (1.361.0)
17+
aws-sdk-ec2 (1.375.0)
1818
aws-sdk-core (~> 3, >= 3.165.0)
1919
aws-sigv4 (~> 1.1)
2020
aws-sigv4 (1.5.2)
2121
aws-eventstream (~> 1, >= 1.0.2)
22-
bindata (2.4.14)
22+
bindata (2.4.15)
2323
bolt (3.26.2)
2424
CFPropertyList (~> 2.2)
2525
addressable (~> 2.5)
@@ -49,7 +49,7 @@ GEM
4949
coderay (1.1.3)
5050
colored2 (3.1.2)
5151
concurrent-ruby (1.1.10)
52-
connection_pool (2.3.0)
52+
connection_pool (2.4.0)
5353
cri (2.15.11)
5454
deep_merge (1.2.2)
5555
dependency_checker (0.3.0)
@@ -65,8 +65,8 @@ GEM
6565
domain_name (0.5.20190701)
6666
unf (>= 0.0.5, < 1.0.0)
6767
erubi (1.12.0)
68-
excon (0.97.2)
69-
facter (4.2.14)
68+
excon (0.99.0)
69+
facter (4.3.1)
7070
hocon (~> 1.3)
7171
thor (>= 1.0.1, < 2.0)
7272
facterdb (1.21.0)
@@ -97,7 +97,7 @@ GEM
9797
faraday-retry (1.0.3)
9898
faraday_middleware (1.2.0)
9999
faraday (~> 1.0)
100-
fast_gettext (2.2.0)
100+
fast_gettext (2.3.0)
101101
ffi (1.15.5)
102102
ffi-compiler (1.0.1)
103103
ffi (>= 1.0.0)
@@ -117,12 +117,12 @@ GEM
117117
gyoku (1.4.0)
118118
builder (>= 2.1.2)
119119
rexml (~> 3.0)
120-
hiera (3.11.0)
120+
hiera (3.12.0)
121121
hiera-eyaml (3.3.0)
122122
highline
123123
optimist
124124
highline (2.1.0)
125-
hocon (1.3.1)
125+
hocon (1.4.0)
126126
honeycomb-beeline (2.11.0)
127127
libhoney (>= 1.14.2)
128128
http (5.1.1)
@@ -161,8 +161,8 @@ GEM
161161
mocha (1.16.1)
162162
molinillo (0.8.0)
163163
multi_json (1.15.0)
164-
multipart-post (2.2.3)
165-
net-http-persistent (4.0.1)
164+
multipart-post (2.3.0)
165+
net-http-persistent (4.0.2)
166166
connection_pool (~> 2.2)
167167
net-scp (1.2.1)
168168
net-ssh (>= 2.6.5)
@@ -179,7 +179,7 @@ GEM
179179
parallel (1.22.1)
180180
parallel_tests (3.13.0)
181181
parallel
182-
parser (3.2.0.0)
182+
parser (3.2.2.0)
183183
ast (~> 2.4.1)
184184
pathspec (1.0.0)
185185
pluginator (1.5.0)
@@ -259,7 +259,7 @@ GEM
259259
puppet-strings (3.0.1)
260260
rgen (~> 0.9.0)
261261
yard (~> 0.9.5)
262-
puppet-syntax (3.2.1)
262+
puppet-syntax (3.3.0)
263263
puppet (>= 5)
264264
rake
265265
puppet_forge (3.2.0)
@@ -300,23 +300,23 @@ GEM
300300
rainbow (3.1.1)
301301
rake (13.0.6)
302302
rb-readline (0.5.5)
303-
regexp_parser (2.6.2)
303+
regexp_parser (2.7.0)
304304
retryable (3.0.5)
305305
rexml (3.2.5)
306306
rgen (0.9.1)
307307
rspec (3.12.0)
308308
rspec-core (~> 3.12.0)
309309
rspec-expectations (~> 3.12.0)
310310
rspec-mocks (~> 3.12.0)
311-
rspec-core (3.12.0)
311+
rspec-core (3.12.1)
312312
rspec-support (~> 3.12.0)
313313
rspec-expectations (3.12.2)
314314
diff-lcs (>= 1.2.0, < 2.0)
315315
rspec-support (~> 3.12.0)
316316
rspec-its (1.3.0)
317317
rspec-core (>= 3.0.0)
318318
rspec-expectations (>= 3.0.0)
319-
rspec-mocks (3.12.3)
319+
rspec-mocks (3.12.5)
320320
diff-lcs (>= 1.2.0, < 2.0)
321321
rspec-support (~> 3.12.0)
322322
rspec-puppet (2.12.0)
@@ -338,15 +338,15 @@ GEM
338338
rubocop-ast (>= 1.2.0, < 2.0)
339339
ruby-progressbar (~> 1.7)
340340
unicode-display_width (>= 1.4.0, < 2.0)
341-
rubocop-ast (1.24.1)
342-
parser (>= 3.1.1.0)
341+
rubocop-ast (1.28.0)
342+
parser (>= 3.2.1.0)
343343
rubocop-performance (1.9.1)
344344
rubocop (>= 0.90.0, < 2.0)
345345
rubocop-ast (>= 0.4.0)
346346
rubocop-rspec (2.0.1)
347347
rubocop (~> 1.0)
348348
rubocop-ast (>= 1.1.0)
349-
ruby-progressbar (1.11.0)
349+
ruby-progressbar (1.13.0)
350350
ruby2_keywords (0.0.5)
351351
ruby_smb (1.1.0)
352352
bindata
@@ -355,8 +355,8 @@ GEM
355355
rubyntlm (0.6.3)
356356
rubyzip (2.3.2)
357357
scanf (1.0.0)
358-
semantic_puppet (1.0.4)
359-
serverspec (2.42.1)
358+
semantic_puppet (1.1.0)
359+
serverspec (2.42.2)
360360
multi_json
361361
rspec (~> 3.0)
362362
rspec-its
@@ -423,7 +423,6 @@ GEM
423423
puppet-lint-unquoted_string-check (~> 2.2)
424424
puppet-lint-variable_contains_upcase (~> 1.2)
425425
puppet-lint-version_comparison-check (~> 1.1)
426-
webrick (1.7.0)
427426
windows_error (0.1.5)
428427
winrm (2.3.6)
429428
builder (>= 2.1.2)
@@ -439,8 +438,7 @@ GEM
439438
logging (>= 1.6.1, < 3.0)
440439
rubyzip (~> 2.0)
441440
winrm (~> 2.0)
442-
yard (0.9.28)
443-
webrick (~> 1.7.0)
441+
yard (0.9.34)
444442

445443
PLATFORMS
446444
ruby

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ Puppet Nodes
8989
- Windows 2019
9090
- RHEL 8
9191

92+
To support legacy version of Puppet Enterprise (Before changing naming standard to Primary server from master.) You must set the support_legacy_pe parameter to true.
93+
9294
## Development
9395

9496
If you find any issues with this module, please log them in the issues register of the GitHub project. [Issues][1]

REFERENCE.md

+9
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ The following parameters are available in the `update_trusted_facts::update_trus
9898
* [`preserve_existing_facts`](#preserve_existing_facts)
9999
* [`ignore_infra_status_error`](#ignore_infra_status_error)
100100
* [`noop`](#noop)
101+
* [`support_legacy_pe`](#support_legacy_pe)
101102
* [`pp_role`](#pp_role)
102103
* [`pp_uuid`](#pp_uuid)
103104
* [`pp_environment`](#pp_environment)
@@ -160,6 +161,14 @@ Run the plan in noop. csr_attributes.yaml will still generated, however certific
160161

161162
Default value: ``false``
162163

164+
##### <a name="support_legacy_pe"></a>`support_legacy_pe`
165+
166+
Data type: `Boolean`
167+
168+
Attempt to support legacy PE. Default: false
169+
170+
Default value: ``false``
171+
163172
##### <a name="pp_role"></a>`pp_role`
164173

165174
Data type: `Optional[String]`

metadata.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "benjaminrobertson-update_trusted_facts",
3-
"version": "0.2.0",
3+
"version": "1.0.0",
44
"author": "benjaminrobertson",
55
"summary": "Plan for Puppet enterprise to update trusted facts on nodes.",
66
"license": "Apache-2.0",
@@ -9,7 +9,7 @@
99
"dependencies": [
1010
{
1111
"name": "puppetlabs/stdlib",
12-
"version_requirement": ">= 5.2.0 < 8.0.0"
12+
"version_requirement": ">= 5.2.0 < 9.0.0"
1313
}
1414
],
1515
"operatingsystem_support": [
@@ -50,7 +50,8 @@
5050
{
5151
"operatingsystem": "Rocky",
5252
"operatingsystemrelease": [
53-
"8"
53+
"8",
54+
"9"
5455
]
5556
},
5657
{
@@ -76,7 +77,7 @@
7677
"requirements": [
7778
{
7879
"name": "puppet",
79-
"version_requirement": ">= 7.21.0 < 8.0.0"
80+
"version_requirement": ">= 6.0.0 < 9.0.0"
8081
}
8182
],
8283
"pdk-version": "2.6.1",

plans/update_trusted_facts.pp

+16-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# @param preserve_existing_facts Whether to preserve existing facts from the nodes. If set to false all existing facts will be wiped and replaced with those set in the plan. Default: true
1616
# @param ignore_infra_status_error Ignore errors from 'puppet infrastructure status' command. This is used to verify the primary server. Can be used to allow the plan the run when some PE components are unavaliable. Default: false
1717
# @param noop Run the plan in noop. csr_attributes.yaml will still generated, however certificates will not be resigned. Default: false
18+
# @param support_legacy_pe Attempt to support legacy PE. Default: false
1819
# @param pp_role Set the pp_role trusted fact. Default: undef
1920
# @param pp_uuid Set the pp_uuid trusted fact. Default: undef
2021
# @param pp_environment Set the pp_environment trusted fact. Default: undef
@@ -47,6 +48,7 @@
4748
Boolean $preserve_existing_facts = true,
4849
Boolean $ignore_infra_status_error = false,
4950
Boolean $noop = false,
51+
Boolean $support_legacy_pe = false,
5052
Optional[String] $pp_role = undef,
5153
Optional[String] $pp_uuid = undef,
5254
Optional[String] $pp_environment = undef,
@@ -115,6 +117,18 @@
115117
if length("${confirm_pe_primary_server_results.ok_set}") <= 2 {
116118
fail_plan("Primary server provided not the primary server for this Puppet Enterprise installation: ${pe_server_target.name} ")
117119
}
120+
# Check if we are attempting to support legacy PE.
121+
if $support_legacy_pe {
122+
if $confirm_pe_primary_server_results[0].message =~ /^Master server/ {
123+
$am_i_primary = 'master'
124+
out::message("Detected ${am_i_primary}, using ${am_i_primary} for agent_cert_regen plan")
125+
} else {
126+
$am_i_primary = 'primary'
127+
out::message("Detected ${am_i_primary}, using ${am_i_primary} for agent_cert_regen plan")
128+
}
129+
} else {
130+
$am_i_primary = 'primary'
131+
}
118132

119133
# Create hash with trusted facts
120134
$new_trusted = $trusted_fact_names.reduce({}) | $memo, $value | {
@@ -144,8 +158,8 @@
144158
if $nodes_to_regen_cert != undef {
145159
if $noop != true {
146160
run_plan('enterprise_tasks::agent_cert_regen',
147-
'primary' => $pe_primary_server,
148-
'agent' => $nodes_to_regen_cert)
161+
$am_i_primary => $pe_primary_server,
162+
'agent' => $nodes_to_regen_cert)
149163
}
150164
}
151165
}

tasks/confirm_primary_server.rb

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ def get_primary_hostname(ignore_infra_status_error)
1515
end
1616
end
1717
output.each_line do |line|
18-
if line.match(/^Primary: |^Master: /)
19-
primary = line.gsub(/^Primary: |^Master: /, '').lstrip.rstrip
20-
return primary
18+
if line.match(/^Primary: /)
19+
primary = line.gsub(/^Primary: /, '').lstrip.rstrip
20+
return [ primary, 'Primary' ]
21+
elsif line.match(/^Master: /)
22+
master = line.gsub(/^Master: /, '').lstrip.rstrip
23+
return [ master, 'Master' ]
2124
end
2225
end
2326
puts 'No Primary server found in output. Are you sure you specified the correct server as primary?'
@@ -33,8 +36,8 @@ def get_primary_hostname(ignore_infra_status_error)
3336
primary = get_primary_hostname(ignore_infra_status_error)
3437

3538
# Confirm primary server matches
36-
if primary == pe_primary_server
37-
puts 'Primary server match successful'
39+
if primary[0] == pe_primary_server
40+
puts "#{primary[1]} server match successful"
3841
exit 0
3942
else
4043
puts "Primary server did not match as expected, recieved #{primary} expected #{pe_primary_server}"

tasks/set_csr_attributes.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ def csr_attribute_location
5252

5353
def get_existing_csr(csr_attr_file_location)
5454
if File.exist?(csr_attr_file_location)
55-
data = YAML.safe_load(File.read(csr_attr_file_location))
55+
begin
56+
data = YAML.safe_load(File.read(csr_attr_file_location))
57+
rescue => exception
58+
nil
59+
end
5660
else
5761
nil
5862
end

0 commit comments

Comments
 (0)