Skip to content

Instantly share code, notes, and snippets.

@initcron
Created April 7, 2014 06:48
Show Gist options
  • Save initcron/10015775 to your computer and use it in GitHub Desktop.
Save initcron/10015775 to your computer and use it in GitHub Desktop.
action_destroy for swap/providers/file.rb
action :destroy do
resource_name = new_resource.file_name.gsub('/', '_')
execute "swapoff#{resource_name}" do
command "swapoff #{new_resource.file_name}"
only_if "grep -q #{new_resource.file_name} /proc/swaps"
end
execute "delete#{resource_name}" do
command "rm -rf #{new_resource.file_name}"
only_if { ::File.exists?(new_resource.file_name) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment