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

Commit

Permalink
Merge pull request #8 from orgsync/fix-persist-during-fallback
Browse files Browse the repository at this point in the history
Swap settings fail to persist during fallback command
  • Loading branch information
Seth Vargo committed Jul 4, 2013
2 parents 011701f + 76bf311 commit 4b8eacf
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions libraries/swapfile_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,11 @@ def action_create
Chef::Log.debug("#{@new_resource} already created - nothing to do")
else
begin
create_swapfile(command)
set_permissions
mkswap
swapon
persist if persist?
do_create(command)
rescue Mixlib::ShellOut::ShellCommandFailed => e
Chef::Log.info("#{@new_resource} Rescuing failed swapfile creation for #{@new_resource.path}")
Chef::Log.debug("#{@new_resource} Exception when creating swapfile #{@new_resource.path}: #{e}")
create_swapfile(fallback_command)
set_permissions
mkswap
swapon
do_create(fallback_command)
end
end
end
Expand All @@ -43,6 +36,14 @@ def action_remove

protected

def do_create(command)
create_swapfile(command)
set_permissions
mkswap
swapon
persist if persist?
end

def create_swapfile(command)
shell_out!(command)
Chef::Log.info("#{@new_resource} Creating empty file at #{@new_resource.path}")
Expand Down

0 comments on commit 4b8eacf

Please sign in to comment.