Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions plans/patch_batch.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

# get nodes that are 'clean' from health check results
$nodes_to_patch = ($health_checks.filter_set |$item| { $item.value['state'] == 'clean' }).map |$n| { $n.target }
$health_check_failed = ($health_checks.filter_set |$item| { $item.status == 'failure' }).map |$n| { $n.name }.sort
$health_check_failed = ($health_checks.filter_set |$item| { $item.status == 'failure' }).names

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh lol, I wasn't aware of .names

@rwaffen rwaffen Mar 5, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works only with sets. if you .filter an ok_set you dont really have a set anymore and that does not work, so i use filter_set and then can use .names 🤷

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have this as a bookmark and should read it more ofter 😄
https://help.puppet.com/bolt/current/topics/bolt_types_reference.htm


if $debug {
out::message('patch_batch.pp: Nodes to patch after health check:')
Expand Down Expand Up @@ -85,22 +85,13 @@
out::message($patching_result)
}

$no_patches = $patching_result.ok_set.filter |$item| {
$item.value['packages_updated'].empty
}.map |$n| { $n.name }.sort

$with_patches = $patching_result.ok_set.filter |$item| {
! $item.value['packages_updated'].empty
}.map |$n| { $n.name }.sort

$reboot_required = $patching_result.ok_set.filter |$item| {
$item.value['reboot_required'] == true
}.map |$n| { $n.name }.sort

$targets = get_targets($batch).map |$t| { $t.name }.sort
$no_patches = $patching_result.ok_set.filter_set |$item| { $item.value['packages_updated'].empty }.names
$with_patches = $patching_result.ok_set.filter_set |$item| { ! $item.value['packages_updated'].empty }.names
$reboot_required = $patching_result.ok_set.filter_set |$item| { $item.value['reboot_required'] == true }.names
$targets = get_targets($batch).map |$t| { $t.name }.sort

$output = {
failed => $patching_result.error_set.map |$n| { $n.name }.sort,
failed => $patching_result.error_set.names,
health_check => $run_health_check,
health_check_failed => $health_check_failed,
no_patches => $no_patches,
Expand Down
Loading