|
1 | | -# @summary Checks each node to see if Puppet is installed, then gather Facts on all nodes. |
| 1 | +# @summary Checks each node to see if Puppet is installed, then gather Facts on all targets. |
2 | 2 | # |
3 | 3 | # Executes the <code>puppet_agent::version</code> task to check if Puppet is installed |
4 | | -# on all of the nodes. Once finished, the result is split into two groups: |
| 4 | +# on all of the targets. Once finished, the result is split into two groups: |
5 | 5 | # |
6 | | -# 1. Nodes with puppet |
7 | | -# 2. Nodes with no puppet |
| 6 | +# 1. Targets with puppet |
| 7 | +# 2. Targets with no puppet |
8 | 8 | # |
9 | | -# The nodes with puppet are queried for facts using the <code>patching::puppet_facts</code> plan. |
10 | | -# Nodes without puppet are queried for facts using the simpler <code>facts</code> plan. |
| 9 | +# The targets with puppet are queried for facts using the <code>patching::puppet_facts</code> plan. |
| 10 | +# Targets without puppet are queried for facts using the simpler <code>facts</code> plan. |
11 | 11 | # |
12 | 12 | # This plan is designed to be the first plan executed in a patching workflow. |
13 | 13 | # It can be used to stop the patching process if any hosts are offline by setting |
14 | | -# <code>filter_offline_nodes=false</code> (default). It can also be used |
15 | | -# to patch any hosts that are currently available and ignoring any offline nodes |
16 | | -# by setting <code>filter_offline_nodes=true</code>. |
| 14 | +# <code>filter_offline_targets=false</code> (default). It can also be used |
| 15 | +# to patch any hosts that are currently available and ignoring any offline targets |
| 16 | +# by setting <code>filter_offline_targets=true</code>. |
17 | 17 | # |
18 | | -# @param [TargetSpec] nodes |
| 18 | +# @param [TargetSpec] targets |
19 | 19 | # Set of targets to run against. |
20 | | -# @param [Boolean] filter_offline_nodes |
21 | | -# Flag to determine if offline nodes should be filtered out of the list of targets |
| 20 | +# @param [Boolean] filter_offline_targets |
| 21 | +# Flag to determine if offline targets should be filtered out of the list of targets |
22 | 22 | # returned by this plan. If true, when running the <code>puppet_agent::version</code> |
23 | | -# check, any nodes that return an error will be filtered out and ignored. |
| 23 | +# check, any targets that return an error will be filtered out and ignored. |
24 | 24 | # Those targets will not be returned in any of the data structures in the result of |
25 | | -# this plan. If false, then any nodes that are offline will cause this plan to error |
| 25 | +# this plan. If false, then any targets that are offline will cause this plan to error |
26 | 26 | # immediately when performing the online check. This will result in a halt of the |
27 | 27 | # patching process. |
28 | 28 | # |
29 | 29 | # @return [Struct[{has_puppet => Array[TargetSpec], |
30 | 30 | # no_puppet => Array[TargetSpec], |
31 | 31 | # all => Array[TargetSpec]}]] |
32 | 32 | # |
33 | | -# @example CLI - Basic usage (error if any nodes are offline) |
34 | | -# bolt plan run patching::check_puppet --nodes linux_hosts |
| 33 | +# @example CLI - Basic usage (error if any targets are offline) |
| 34 | +# bolt plan run patching::check_puppet --targets linux_hosts |
35 | 35 | # |
36 | | -# @example CLI - Filter offline nodes (only return online nodes) |
37 | | -# bolt plan run patching::check_puppet --nodes linux_hosts filter_offline_nodes=true |
| 36 | +# @example CLI - Filter offline targets (only return online targets) |
| 37 | +# bolt plan run patching::check_puppet --targets linux_hosts filter_offline_targets=true |
38 | 38 | # |
39 | | -# @example Plan - Basic usage (error if any nodes are offline) |
40 | | -# $results = run_plan('patching::check_puppet', |
41 | | -# nodes => $linux_hosts) |
| 39 | +# @example Plan - Basic usage (error if any targets are offline) |
| 40 | +# $results = run_plan('patching::check_puppet', $linux_hosts) |
42 | 41 | # $targets_has_puppet = $results['has_puppet'] |
43 | 42 | # $targets_no_puppet = $results['no_puppet'] |
44 | 43 | # $targets_all = $results['all'] |
45 | 44 | # |
46 | | -# @example Plan - Filter offline nodes (only return online nodes) |
47 | | -# $results = run_plan('patching::check_puppet', |
48 | | -# nodes => $linux_hosts, |
49 | | -# filter_offline_nodes => true) |
| 45 | +# @example Plan - Filter offline targets (only return online targets) |
| 46 | +# $results = run_plan('patching::check_puppet', $linux_hosts, |
| 47 | +# filter_offline_targets => true) |
50 | 48 | # $targets_online_has_puppet = $results['has_puppet'] |
51 | 49 | # $targets_online_no_puppet = $results['no_puppet'] |
52 | 50 | # $targets_online = $results['all'] |
53 | 51 | # |
54 | 52 | plan patching::check_puppet ( |
55 | | - TargetSpec $nodes, |
56 | | - Boolean $filter_offline_nodes = false, |
| 53 | + TargetSpec $targets, |
| 54 | + Boolean $filter_offline_targets = false, |
57 | 55 | ) { |
58 | | - $targets = get_targets($nodes) |
59 | | - ## This will check all nodes to verify online by checking their Puppet agent version |
60 | | - $targets_version = run_task('puppet_agent::version', $targets, |
61 | | - _catch_errors => $filter_offline_nodes) |
62 | | - # if we're filtering out offline nodes, then only accept the ok_set from the task above |
63 | | - if $filter_offline_nodes { |
| 56 | + $_targets = get_targets($targets) |
| 57 | + ## This will check all targets to verify online by checking their Puppet agent version |
| 58 | + $targets_version = run_task('puppet_agent::version', $_targets, |
| 59 | + _catch_errors => $filter_offline_targets) |
| 60 | + # if we're filtering out offline targets, then only accept the ok_set from the task above |
| 61 | + if $filter_offline_targets { |
64 | 62 | $targets_filtered = $targets_version.ok_set |
65 | 63 | } |
66 | 64 | else { |
|
74 | 72 | if !$targets_with_puppet.empty() { |
75 | 73 | # run `puppet facts` on targets with Puppet because it returns a more complete |
76 | 74 | # set of facts than just running `facter` |
77 | | - run_plan('patching::puppet_facts', |
78 | | - nodes => $targets_with_puppet) |
| 75 | + run_plan('patching::puppet_facts', $targets_with_puppet) |
79 | 76 | } |
80 | 77 | if !$targets_no_puppet.empty() { |
81 | 78 | # run `facter` if it's available otherwise get basic facts |
82 | | - run_plan('facts', |
83 | | - nodes => $targets_no_puppet) |
| 79 | + run_plan('facts', $targets_no_puppet) |
84 | 80 | } |
85 | 81 |
|
86 | 82 | return({ |
|
0 commit comments