Skip to content

Instantly share code, notes, and snippets.

@flomotlik
Created September 12, 2013 08:50
Show Gist options
  • Select an option

  • Save flomotlik/6534645 to your computer and use it in GitHub Desktop.

Select an option

Save flomotlik/6534645 to your computer and use it in GitHub Desktop.
Setting up our Amazon machines
# Creating the EC2 Instance
instance = ec2.instances.create(
:image_id => "ami-7739b41e",
:instance_type => 'cc2.8xlarge',
:key_name => "CloudshipCreateServerKey",
:instance_initiated_shutdown_behavior => 'terminate',
:block_device_mappings => {
"/dev/sda1" => {
:volume_size => 50,
:delete_on_termination => true
}
})
# Pushing scripts into the server and start building the machine
Net::SSH.start(instance.ip_address) do |ssh|
`tar -czf scripts.tar.gz *`
ssh.sftp.upload!("./scripts.tar.gz", "/root/scripts.tar.gz")
ssh.exec! "sudo mkdir /root/scripts"
ssh.exec! "sudo tar xf /root/scripts.tar.gz -C /root/scripts"
ssh.exec "sudo nohup time /bin/bash /root/scripts/server_setup/host/start_host.sh #{ENV['AWS_KEY']} #{ENV['AWS_SECRET_KEY']} #{instance.id} &> /dev/null &"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment