Skip to content

Instantly share code, notes, and snippets.

@marcusmalmberg
Created July 4, 2012 15:24
Show Gist options
  • Save marcusmalmberg/3047882 to your computer and use it in GitHub Desktop.
Save marcusmalmberg/3047882 to your computer and use it in GitHub Desktop.
create_swapfile recipe
swapfile path = '/mnt/swapfile'
swapfile_bs = '1M'
swapfile_count = '1024'
execute "create_swapfile" do
Chef::Log.info "About to create swapfile if it doesn't exist"
command %Q{
sudo dd if=/dev/zero of=#{swapfile_path} bs=#{swapfile_bs} count=#{swapfile_count} && \
sudo mkswap #{swapfile_path} && \
sudo swapon #{swapfile_path}
}
not_if { File.exists? swapfile_path }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment