Skip to content

Instantly share code, notes, and snippets.

@petems
Created April 22, 2016 21:25
Show Gist options
  • Save petems/b5efe6d9fb65e396facc0a79ed7a4528 to your computer and use it in GitHub Desktop.
Save petems/b5efe6d9fb65e396facc0a79ed7a4528 to your computer and use it in GitHub Desktop.
$swapfile_path = '/mnt/swap.1'
$margin = '5MB'
$expected_swapfile_size = '200MB'
if ($::swapfile_sizes and is_hash($::swapfile_sizes)) {
$margin_bytes = to_bytes($margin)
$existing_swapfile_bytes = to_bytes("${::swapfile_sizes[$swapfile_path]}kb")
$expected_swapfile_size_bytes = to_bytes($expected_swapfile_size)
if has_key($::swapfile_sizes,$swapfile_path) {
notify{'Swapfile already present! Checking size':}
if ($expected_swapfile_size_bytes == $existing_swapfile_bytes) {
notify{"Existing Swapfile does match size exactly!":}
} else {
notify{"Existing Swapfile does not match size exactly, checking against margin (${margin})":}
notify{"Existing: $existing_swapfile_bytes":}
notify{"Expected: $expected_swapfile_size_bytes":}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment