Skip to content

Instantly share code, notes, and snippets.

@charlesjohnson
Created October 15, 2013 23:01
Show Gist options
  • Save charlesjohnson/6999985 to your computer and use it in GitHub Desktop.
Save charlesjohnson/6999985 to your computer and use it in GitHub Desktop.
use_inline_resources
action :create do
resource_name = new_resource.file_name.gsub('/', '_')
execute "create#{resource_name}" do
command "dd if=/dev/zero of=#{new_resource.file_name} bs=1024 count=#{new_resource.blocks}"
not_if { ::File.exists?(new_resource.file_name) }
notifies :run, "execute[mkswap#{resource_name}]", :immediately
end
execute "mkswap#{resource_name}" do
command "mkswap #{new_resource.file_name}"
action :nothing
end
execute "swapon#{resource_name}" do
command "swapon #{new_resource.file_name}"
not_if "grep -q #{new_resource.file_name} /proc/swaps"
end
end
@pyn
Copy link

pyn commented Oct 15, 2013

10x!

@stjohnjohnson
Copy link

Where are the tests?

@FenrirUnbound
Copy link

I heard a red-bar in the room

@stilldavid
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment