Created
April 22, 2016 21:25
-
-
Save petems/b5efe6d9fb65e396facc0a79ed7a4528 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
$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