Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions files/os_patching_fact_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ case $OSFAMILY in
# Security: kernel-3.14.2-200.fc20.x86_64 is the currently running version
# ---
# We need to filter those out as they screw up the package listing
PKGS=$(yum -q check-update 2>/dev/null| egrep -v "^[Ss]ecurity:" | egrep -i '^[[:alnum:]_-]+\.[[:alnum:]_-]+[[:space:]]+[[:alnum:]_.-]+[[:space:]]+[A-Za-z0-9_.-]+[[:space:]]*$' | awk '/^[[:alnum:]]/ {print $1}')
PKGS=$(yum -q check-update 2>/dev/null| egrep -v "^[Ss]ecurity:" | egrep -i '^[[:alnum:]_-]+\.[[:alnum:]_-]+[[:space:]]+[[:alnum:]_:.-]+[[:space:]]+[A-Za-z0-9_.-]+[[:space:]]*$' | awk '/^[[:alnum:]]/ {print $1}')
PKGS=$(echo $PKGS | sed 's/Obsoleting.*//')
SECPKGS=$(yum -q --security check-update 2>/dev/null| egrep -v "^Security:" | egrep -i '^[[:alnum:]_-]+\.[[:alnum:]_-]+[[:space:]]+[[:alnum:]_.-]+[[:space:]]+[A-Za-z0-9_.-]+[[:space:]]*$' | awk '/^[[:alnum:]]/ {print $1}')
SECPKGS=$(yum -q --security check-update 2>/dev/null| egrep -v "^Security:" | egrep -i '^[[:alnum:]_-]+\.[[:alnum:]_-]+[[:space:]]+[[:alnum:]_:.-]+[[:space:]]+[A-Za-z0-9_.-]+[[:space:]]*$' | awk '/^[[:alnum:]]/ {print $1}')
SECPKGS=$(echo $SECPKGS | sed 's/Obsoleting.*//')
HELDPKGS=$([ -r /etc/yum/pluginconf.d/versionlock.list ] && awk -F':' '/:/ {print $2}' /etc/yum/pluginconf.d/versionlock.list | sed 's/-[0-9].*//')
;;
Expand Down
29 changes: 16 additions & 13 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
# @param patch_window [String]
# A freeform text entry used to allocate a node to a specific patch window (Optional)
#
# @param blackout_windows [Hash]
# Hash of start/end blackout dates+times (Optional)
#
# @param pre_patching_command [Stdlib::AbsolutePath]
# The full path of the command to run prior to running patching. Can be used to
# run customised workflows such as gracefully shutting down applications. The entry
Expand All @@ -87,6 +90,9 @@
# @param windows_update_interval_mins
# Control how often windows updates for updates
#
# @param fact_mode
# Mode to set on fact command file
#
# @param ensure
# `present` to install scripts, cronjobs, files, etc, `absent` to cleanup a system that previously hosted us
#
Expand Down Expand Up @@ -160,7 +166,6 @@
Optional[String] $patch_window = undef,
Optional[Hash] $blackout_windows = undef,
) {

# None tunable
$cache_dir = lookup('os_patching::cache_dir',Stdlib::Absolutepath,first,undef)
$fact_dir = lookup('os_patching::fact_dir',Stdlib::Absolutepath,first,undef)
Expand All @@ -171,7 +176,7 @@
default => undef,
}

case $::kernel {
case $facts['kernel'] {
'FreeBSD', 'Linux': {
File {
owner => $patch_data_owner,
Expand Down Expand Up @@ -272,16 +277,16 @@
if ($blackout_windows) {
# Validate the information in the blackout_windows hash
$blackout_windows.each | String $key, Hash $value | {
if ( $key !~ /^[A-Za-z0-9_ ]+$/ ){
if ( $key !~ /^[A-Za-z0-9_ ]+$/ ) {
fail('Blackout description can only contain alphanumerics, space and underscore')
}
if ( $value['start'] !~ /^\d{,5}-\d{1,2}-\d{1,2}T\d{,2}:\d{,2}:\d{,2}[-\+]\d{,2}:\d{,2}$/ ){
if ( $value['start'] !~ /^\d{,5}-\d{1,2}-\d{1,2}T\d{,2}:\d{,2}:\d{,2}[-\+]\d{,2}:\d{,2}$/ ) {
fail('Blackout start time must be in ISO 8601 format (YYYY-MM-DDTmm:hh:ss[-+]hh:mm)')
}
if ( $value['end'] !~ /^\d{,5}-\d{1,2}-\d{1,2}T\d{,2}:\d{,2}:\d{,2}[-\+]\d{,2}:\d{,2}$/ ){
if ( $value['end'] !~ /^\d{,5}-\d{1,2}-\d{1,2}T\d{,2}:\d{,2}:\d{,2}[-\+]\d{,2}:\d{,2}$/ ) {
fail('Blackout end time must be in ISO 8601 format (YYYY-MM-DDTmm:hh:ss[-+]hh:mm)')
}
if ( $value['start'] > $value['end'] ){
if ( $value['start'] > $value['end'] ) {
fail('Blackout end time must after the start time')
}
}
Expand All @@ -295,7 +300,7 @@
file { "${cache_dir}/blackout_windows":
ensure => $blackout_windows_ensure,
content => epp("${module_name}/blackout_windows.epp", {
'blackout_windows' => pick($blackout_windows, {}),
'blackout_windows' => pick($blackout_windows, {}),
}),
require => File[$cache_dir],
}
Expand All @@ -315,9 +320,8 @@
}
}

case $::kernel {
case $facts['kernel'] {
'FreeBSD', 'Linux': {

if ( $facts['os']['family'] == 'RedHat' and $manage_yum_utils) {
package { 'yum-utils':
ensure => $yum_utils,
Expand Down Expand Up @@ -386,7 +390,6 @@
}
}
'windows': {

if $fact_exec {
exec { $fact_exec:
path => 'C:/Windows/System32/WindowsPowerShell/v1.0',
Expand All @@ -399,7 +402,7 @@
scheduled_task { 'os_patching fact generation':
ensure => $ensure,
enabled => true,
command => "${::system32}/WindowsPowerShell/v1.0/powershell.exe",
command => "${facts['os']['windows']['system32']}/WindowsPowerShell/v1.0/powershell.exe",
arguments => "-NonInteractive -ExecutionPolicy RemoteSigned -File ${fact_cmd}",
user => 'SYSTEM',
trigger => [
Expand All @@ -410,11 +413,11 @@
},
{
schedule => 'boot',
}
},
],
require => File[$fact_cmd],
}
}
default: { fail('Unsupported OS')}
default: { fail('Unsupported OS') }
}
}
2 changes: 2 additions & 0 deletions pdk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
ignore: []