Puppet Plan: patching::snapshot_kvm
- Defined in:
- plans/snapshot_kvm.pp
Summary
Creates or deletes VM snapshots on targets in KVM/Libvirt.Overview
Runs commands on the CLI of the KVM/Libvirt hypervisor host.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'plans/snapshot_kvm.pp', line 47
plan patching::snapshot_kvm (
TargetSpec $targets,
Enum['create', 'delete'] $action,
Optional[Enum['hostname', 'name', 'uri']] $target_name_property = undef,
Optional[String[1]] $snapshot_name = undef,
Optional[String] $snapshot_description = undef,
Optional[Boolean] $snapshot_memory = undef,
Optional[Boolean] $snapshot_quiesce = undef,
Optional[TargetSpec] $hypervisor_targets = undef,
Boolean $noop = false,
) {
$_targets = run_plan('patching::get_targets', $targets)
$group_vars = $_targets[0].vars
# Order: CLI > Config > Default
$_target_name_property = pick($target_name_property,
$group_vars['patching_snapshot_target_name_property'],
'uri')
$_snapshot_name = pick($snapshot_name,
$group_vars['patching_snapshot_name'],
'Bolt Patching Snapshot')
$_snapshot_description = pick_default($snapshot_description,
$group_vars['patching_snapshot_description'],
'Bolt Patching Snapshot')
$_snapshot_memory = pick($snapshot_memory,
$group_vars['patching_snapshot_memory'],
false)
$_snapshot_quiesce = pick($snapshot_quiesce,
$group_vars['patching_snapshot_quiesce'],
false)
$_hypervisor_targets = pick($hypervisor_targets,
$group_vars['patching_snapshot_kvm_hypervisor_targets'],
'kvm_hypervisors')
# Create array of node names
$vm_names = patching::target_names($_targets, $_target_name_property)
# Display status message
if $action == 'create' {
out::message("Creating VM snapshot '${_snapshot_name}' for:")
$vm_names.each |$n| {
out::message(" + ${n}")
}
} else {
out::message("Deleting VM snapshot '${_snapshot_name}' for:")
$vm_names.each |$n| {
out::message(" - ${n}")
}
}
if !$noop {
return(run_task('patching::snapshot_kvm', $_hypervisor_targets,
vm_names => $vm_names,
snapshot_name => $_snapshot_name,
snapshot_description => $_snapshot_description,
snapshot_memory => $_snapshot_memory,
snapshot_quiesce => $_snapshot_quiesce,
action => $action))
}
}
|