File tree 5 files changed +59
-0
lines changed
5 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 20
20
* [ ` peadm::assert_supported_pe_version ` ] ( #peadm--assert_supported_pe_version ) : Assert that the PE version given is supported by PEAdm
21
21
* [ ` peadm::bolt_version ` ] ( #peadm--bolt_version )
22
22
* [ ` peadm::certname ` ] ( #peadm--certname ) : Return the certname of the given target-like input
23
+ * [ ` peadm::check_availability ` ] ( #peadm--check_availability ) : check if a group of targets are reachable for bolt
23
24
* [ ` peadm::check_version_and_known_hosts ` ] ( #peadm--check_version_and_known_hosts ) : Checks PE verison and warns about setting r10k_known_hosts
24
25
* [ ` peadm::convert_hash ` ] ( #peadm--convert_hash ) : converts two arrays into hash
25
26
* [ ` peadm::convert_status ` ] ( #peadm--convert_status ) : Transforms a value in a human readable status with or without colors
@@ -266,6 +267,30 @@ Variant[Target,
266
267
267
268
268
269
270
+ ### <a name =" peadm--check_availability " ></a >` peadm::check_availability `
271
+
272
+ Type: Puppet Language
273
+
274
+ check if a group of targets are reachable for bolt
275
+
276
+ #### ` peadm::check_availability(TargetSpec $targets, Boolean $output_details = true) `
277
+
278
+ The peadm::check_availability function.
279
+
280
+ Returns: ` Integer ` counter for unavailable nodes
281
+
282
+ ##### ` targets `
283
+
284
+ Data type: ` TargetSpec `
285
+
286
+ list of targets that are going to be checked
287
+
288
+ ##### ` output_details `
289
+
290
+ Data type: ` Boolean `
291
+
292
+ flag to enable/disable error output for failed nodes
293
+
269
294
### <a name =" peadm--check_version_and_known_hosts " ></a >` peadm::check_version_and_known_hosts `
270
295
271
296
Type: Puppet Language
Original file line number Diff line number Diff line change
1
+ #
2
+ # @summary check if a group of targets are reachable for bolt
3
+ #
4
+ # @param targets list of targets that are going to be checked
5
+ # @param output_details flag to enable/disable error output for failed nodes
6
+ #
7
+ # @return counter for unavailable nodes
8
+ #
9
+ # @author Tim Meusel <[email protected] >
10
+ #
11
+ function peadm::check_availability(
12
+ TargetSpec $targets ,
13
+ Boolean $output_details = true
14
+ ) >> Integer {
15
+ $check_result = wait_until_available($targets , wait_time => 2, _catch_errors => true )
16
+ if $check_result .ok {
17
+ } else {
18
+ $messages = $check_result .error_set.map |$result | {
19
+ " ## node ${result.target} has connection error '${result.error.kind}' with message '${result.error.msg}'"
20
+ }
21
+ $end_message = " ${check_result.error_set.count} targets are not reachable, stopping plan"
22
+ $fail_message = $output_details ? {
23
+ true => " ${messages.join(" \n" )}\n ${end_message} " ,
24
+ false => $end_message ,
25
+ }
26
+ fail_plan($fail_message )
27
+ }
28
+
29
+ return $check_result .error_set.count
30
+ }
Original file line number Diff line number Diff line change 56
56
)
57
57
58
58
out::message(' # Gathering information' )
59
+ peadm::check_availability($pe_installer_targets )
59
60
60
61
# Get trusted fact information for all compilers. Use peadm::certname() as
61
62
# the hash key because the apply block below will break trying to parse the
Original file line number Diff line number Diff line change 76
76
) {
77
77
peadm::assert_supported_bolt_version()
78
78
79
+ out::message(' # Gathering information' )
80
+ peadm::check_availability($pe_installer_targets )
79
81
peadm::assert_supported_pe_version($version , $permit_unsafe_versions )
80
82
81
83
$install_result = run_plan(' peadm::subplans::install' ,
Original file line number Diff line number Diff line change 98
98
])
99
99
100
100
out::message(' # Gathering information' )
101
+ peadm::check_availability($pe_installer_targets )
101
102
102
103
# lint:ignore:strict_indent
103
104
$primary_target .peadm::fail_on_transport(' pcp' , @(HEREDOC/n))
You can’t perform that action at this time.
0 commit comments