Created
March 17, 2020 21:01
-
-
Save tspeigner/755f1b61c780713fbbd185ce1cb03f20 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plan os_patching::patch_node( | |
TargetSpec $target, | |
Boolean $downtime_enable = true, | |
){ | |
## Prevalidation task ( | |
$pre_validate = run_script('os_patching/patch.sh', $target, | |
'arguments' => ['-V'], | |
_catch_errors => true) | |
if $pre_validate.ok() { | |
## update DB with error msg | |
### No errors from patch validation resultset then no patchingf needed | |
## NO patching on node | |
return("Pre_validation successful: no patching needed") | |
} else { | |
##Update status in BD to inprogress | |
## Continue patching ..... | |
out::message("Continue patching .....") | |
} | |
if $downtime_enable{ | |
$downtime_result = run_task('os_patching::schedule_downtime', $target, | |
hostname => $target, | |
_catch_errors => true) | |
if $downtime_result.ok() { | |
out::message("Downtime set on node") | |
}else{ | |
out::message($downtime_result[0].message) | |
fail_plan("Count not get downtime for thing") | |
} | |
} | |
#error handling | |
out::message("Starting Patching Script") | |
$patch_result = run_script('os_patching/patch.sh', $target, | |
'arguments' => ['-j'], | |
_catch_errors => true) | |
if $patch_result.ok() { | |
out::message($patch_result.to_data[0]['result']['stdout']) | |
} else { | |
out::message($patch_result.to_data[0]['result']['stdout']) | |
fail_plan("The patching script failed to work fine") | |
} | |
#error handling | |
$last_reboot = run_task('reboot::last_boot_time', $target) | |
out::message($last_reboot[0].message) | |
#error handling | |
$reboot_result = run_task('reboot', $target, message => 'rebooting due to patching') | |
out::message("Reboot Issued") | |
#error handling | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment