Skip to content

Commit 3446c82

Browse files
authored
Merge branch 'master' into feature/facts
2 parents b06babb + 96371fc commit 3446c82

5 files changed

Lines changed: 29 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ All notable changes to this project will be documented in this file.
1111

1212
Contributed by Nick Maludy (@nmaludy)
1313

14+
* Fixed a bug with a hard coded wait for reboot. (Bug Fix)
15+
16+
Contributed by Michael Surato (@msurato)
17+
18+
* Add `hostname` as a choice for patching::snapshot_vmware::target_name_property
19+
It can be used in cases where target discovery uses fully qualified domain names
20+
and VM names don't have domain name component
21+
22+
Contributed by Vadym Chepkov (@vchepkov)
23+
1424
## Release 1.0.1 (2020-03-04)
1525

1626
* Ensure the `patching.json` file exists on Windows by creating a blank file if it was previously missing.

functions/target_names.pp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
# @param [TargetSpec] targets
44
# List of targets to extract the name from
55
#
6-
# @param [Enum['name', 'uri']] name_property
6+
# @param [Enum['hostname', 'name', 'uri']] name_property
77
# Property in the Target to use as the name
88
#
99
# @return [Array[String]] Array of names, one for each target
1010
function patching::target_names(
1111
TargetSpec $targets,
12-
Enum['name', 'uri'] $name_property,
12+
Enum['hostname', 'name', 'uri'] $name_property,
1313
) >> Array[String] {
1414
$targets.map |$n| {
1515
case $name_property {
16+
'hostname': {
17+
regsubst($n.uri, '^([^.]+).*','\1')
18+
}
1619
'name': {
1720
$n.name
1821
}

plans/init.pp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@
218218

219219
## Check if reboot required and reboot if true.
220220
run_plan('patching::reboot_required', $update_ok_targets,
221-
strategy => $reboot_strategy_group,
222-
message => $reboot_message_group,
223-
noop => $noop)
221+
strategy => $reboot_strategy_group,
222+
message => $reboot_message_group,
223+
reboot_wait => $reboot_wait,
224+
noop => $noop)
224225

225226
## Remove VM snapshots
226227
if $snapshot_delete_group and $snapshot_plan_group and $snapshot_plan_group != 'disabled' {

plans/reboot_required.pp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
# - `resultset` : results from the `reboot` plan for the attempted hosts (potentially an empty `ResultSet`)
3232
#
3333
plan patching::reboot_required (
34-
TargetSpec $targets,
34+
TargetSpec $targets,
3535
Enum['only_required', 'never', 'always'] $strategy = 'only_required',
36-
String $message = 'NOTICE: This system is currently being updated.',
37-
Boolean $noop = false,
36+
String $message = 'NOTICE: This system is currently being updated.',
37+
Boolean $noop = false,
38+
Optional[Integer] $reboot_wait = 300,
3839
) {
3940
$_targets = run_plan('patching::get_targets', $targets)
4041
$group_vars = $_targets[0].vars
@@ -62,7 +63,7 @@
6263
if !$targets_reboot_required.empty() {
6364
$targets_reboot_attempted = $targets_reboot_required
6465
$reboot_resultset = run_plan('reboot', $targets_reboot_required,
65-
reconnect_timeout => 300,
66+
reconnect_timeout => $reboot_wait,
6667
message => $_message,
6768
_catch_errors => true)
6869
}
@@ -74,7 +75,7 @@
7475
'always': {
7576
$targets_reboot_attempted = $targets
7677
$reboot_resultset = run_plan('reboot', $targets,
77-
reconnect_timeout => 300,
78+
reconnect_timeout => $reboot_wait,
7879
message => $_message,
7980
_catch_errors => true)
8081
}

plans/snapshot_vmware.pp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# - `create` creates a new snapshot
2020
# - 'delete' deletes snapshots by matching the `snapshot_name` passed in.
2121
#
22-
# @param [Optional[Enum['name', 'uri']]] target_name_property
22+
# @param [Optional[Enum['hostname', 'name', 'uri']]] target_name_property
2323
# Determines what property on the Target object will be used as the VM name when
2424
# mapping the Target to a VM in vSphere.
2525
#
@@ -28,6 +28,8 @@
2828
# list is set as the `uri` and not the `name`, in this case `name` will be `undef`.
2929
# - `name` : use the `name` property on the Target, this is not preferred because
3030
# `name` is usually a short name or nickname.
31+
# - `hostname`: use the `hostname` value to use host component of `uri` property on the Target
32+
# this can be useful if VM name doesn't include domain name
3133
#
3234
# @param [String[1]] vsphere_host
3335
# Hostname of the vSphere server that we're going to use to create snapshots via the API.
@@ -63,7 +65,7 @@
6365
plan patching::snapshot_vmware (
6466
TargetSpec $targets,
6567
Enum['create', 'delete'] $action,
66-
Optional[Enum['name', 'uri']] $target_name_property = undef,
68+
Optional[Enum['hostname', 'name', 'uri']] $target_name_property = undef,
6769
String[1] $vsphere_host = get_targets($targets)[0].vars['vsphere_host'],
6870
String[1] $vsphere_username = get_targets($targets)[0].vars['vsphere_username'],
6971
String[1] $vsphere_password = get_targets($targets)[0].vars['vsphere_password'],

0 commit comments

Comments
 (0)