-
-
Save krames/8599608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fog' | |
service = Fog::Compute.new( | |
provider: 'rackspace', | |
rackspace_username: ENV['RAX_USERNAME'], | |
rackspace_api_key: ENV['RAX_API_KEY'], | |
rackspace_region: :ord | |
) | |
# Adjust these settings based on your needs. | |
@swapsize = "1048576" | |
@swappiness = "10" | |
puts "creating server." | |
server = service.servers.bootstrap :name => 'bootstrap-server', | |
:flavor_id => service.flavors.first.id, | |
:image_id => service.images.find {|img| img.name =~ /Ubuntu/}.id, | |
:public_key_path => '~/.ssh/id_rsa.pub', | |
:private_key_path => '~/.ssh/id_rsa' | |
puts "server created." | |
# See: | |
# http://www.rackspace.com/knowledge_center/article/create-a-linux-swap-file | |
server.ssh [ | |
"set -e", | |
"dd if=/dev/zero of=/mnt/swapfile bs=1024 count=#{@swapsize}", | |
"mkswap /mnt/swapfile", | |
"swapon /mnt/swapfile", | |
%Q[echo "/mnt/swapfile none swap sw 0 0" >> /etc/fstab], | |
%Q[echo "vm.swappiness=#{@swappiness}" >> /etc/sysctl.conf], | |
"sysctl vm.swappiness=#{@swappiness}" | |
] | |
puts "log in with: ssh root@#{server.ipv4_address}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment