Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Rebased code to use case statement
Browse files Browse the repository at this point in the history
DRY up a lot of the Puppet code
  • Loading branch information
petems committed Nov 12, 2015
1 parent 3ff51a3 commit 08112a6
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions manifests/files.pp
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,16 @@
validate_bool($add_mount)

if $ensure == 'present' {
if $cmd == 'dd' {
exec { "Create swap file ${swapfile}":
command => "/bin/dd if=/dev/zero of=${swapfile} bs=1M count=${swapfilesize_mb}",
creates => $swapfile,
timeout => $timeout,
exec { "Create swap file ${swapfile}":
creates => $swapfile,
timeout => $timeout,
}
case $cmd {
'dd': {
Exec["Create swap file ${swapfile}"] { command => "/bin/dd if=/dev/zero of=${swapfile} bs=1M count=${swapfilesize_mb}" }
}
} else {
exec { "Create swap file ${swapfile}":
command => "/usr/bin/fallocate -l ${swapfilesize_mb}M ${swapfile}",
creates => $swapfile,
timeout => $timeout,
'fallocate': {
Exec["Create swap file ${swapfile}"] { command => "/usr/bin/fallocate -l ${swapfilesize_mb}M ${swapfile}" }
}
}
file { $swapfile:
Expand Down

0 comments on commit 08112a6

Please sign in to comment.