Skip to content

Commit

Permalink
v1.1.3: support linux updates for multiple architectures (#59)
Browse files Browse the repository at this point in the history
* remove arch if there is a multi-arch update

* always set reboot variable

* update changelog for 1.1.3

* bump version to 1.1.3

* linting
  • Loading branch information
kreeuwijk authored Jun 20, 2022
1 parent a4a1d96 commit fb758b9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

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

## Release 1.1.3

**Bugfixes**
- No longer logs `Puppet Unknown variable: 'reboot'` on runs outside of the patch day.

**Improvements**
- Correctly handles multi-architecture package updates, e.g. when there is an update for both the `i686` and `x86_64` version of a package.

## Release 1.1.2

**Bugfixes**
Expand Down
4 changes: 4 additions & 0 deletions functions/process_patch_groups.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ function patching_as_code::process_patch_groups(
repeat => $patching_as_code::patch_schedule[$active_pg]['max_runs']
}
$reboot = $patching_as_code::patch_schedule[$active_pg]['reboot']
} else {
$reboot = 'never'
}
}

Expand Down Expand Up @@ -67,6 +69,8 @@ function patching_as_code::process_patch_groups(
repeat => $patching_as_code::patch_schedule[$patching_as_code::high_priority_patch_group]['max_runs']
}
$high_prio_reboot = $patching_as_code::patch_schedule[$patching_as_code::high_priority_patch_group]['reboot']
} else {
$high_prio_reboot = 'never'
}
}

Expand Down
19 changes: 19 additions & 0 deletions lib/puppet/functions/patching_as_code/dedupe_arch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Puppet::Functions.create_function(:'patching_as_code::dedupe_arch') do
dispatch :dedupe_arch do
param 'Array', :patches
end

def dedupe_arch(patches)
no_arch = patches.map { |patch| patch.sub(%r{(.noarch|.x86_64|.i386|.i686)$}, '') }
multi_arch = no_arch.group_by { |x| x }.select { |_k, v| v.size > 1 }.map(&:first)
result = patches.map do |patch|
no_arch_patch = patch.sub(%r{(.noarch|.x86_64|.i386|.i686)$}, '')
if multi_arch.include? no_arch_patch
no_arch_patch
else
patch
end
end
result.uniq
end
end
6 changes: 3 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@
[]
},
'Linux' => if $bool_patch_day and $security_only and !$high_priority_only{
$facts[$patch_fact]['security_package_updates']
patching_as_code::dedupe_arch($facts[$patch_fact]['security_package_updates'])
} elsif $bool_patch_day and !$high_priority_only{
$facts[$patch_fact]['package_updates']
patching_as_code::dedupe_arch($facts[$patch_fact]['package_updates'])
} else {
[]
},
Expand All @@ -296,7 +296,7 @@
[]
},
'Linux' => if $bool_high_prio_patch_day {
$facts[$patch_fact]['package_updates'].filter |$item| { $item in $high_priority_list }
patching_as_code::dedupe_arch($facts[$patch_fact]['package_updates'].filter |$item| { $item in $high_priority_list })
} else {
[]
},
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-patching_as_code",
"version": "1.1.2",
"version": "1.1.3",
"author": "puppetlabs",
"summary": "Automated patching through desired state code",
"license": "Apache-2.0",
Expand Down

0 comments on commit fb758b9

Please sign in to comment.