Spinning up a new VM - HeroesAndSuch/chef_repo GitHub Wiki

Setting up a simple Ubuntu machine

Spinning up a new VM is pretty easy. Lets spin up an ubuntu 14.04 machine for fun. Note: All commands take place in a non-admin powershell unless otherwise called out.

  • So lets create a VM. The only thing we need to determine before starting is the ID # for your ssh key. To find that, run the following:
 knife digital_ocean sshkey list
  • Make note of the ID # that matches your SSH key.
  • Now lets create the VM:
 knife digital_ocean droplet create --server-name YOUR_SERVER_NAME_HERE.gamingsyndicate.net \
                                    --image ubuntu-14-04-x64 \
                                    --location nyc3 \
                                    --size 512mb \
                                    --ssh-keys YOUR_SSH_ID_HERE \
                                    --bootstrap \
                                    --run-list "recipe[apt],recipe[has_bootstrap]"

Bootstrapping with a specific runlist

This is the same as above, but you can include a specific runlist to go with it, such as:

 knife digital_ocean droplet create --server-name YOUR_NEW_SERVER_NAME_HERE.gamingsyndicate.net \
                                    --image ubuntu-14-04-x64 \
                                    --location nyc3 \
                                    --size 512mb \
                                    --ssh-keys YOUR_SSH_ID_HERE \
                                    --bootstrap \
                                    --run-list "recipe[apt],recipe[has_bootstrap],recipe[has_mumble]" \
  • The above command will make sure apt-get upgrade is run and then it applies the has_mumble cookbook.

Bootstrapping a machine if auto-bootstrap fails

Sometimes the bootstrap will timeout if it takes too long to spin up, so you can bootstrap the machine with this one command:

knife bootstrap IP_ADDRESS_OF_INSTANCE

The IP address if given back to you when the VM is spun up, but if you can't find it for whatever reason, you can use this command to discover it:

knife digital_ocean droplet list

This will show the IP for every instance and you can continue to boot strap it with the command above.

Other bootstrapping troubleshooting steps

ERROR: Net::SSH::HostKeyMismatch: fingerprint

If you get an error that contains ERROR: Net::SSH::HostKeyMismatch: fingerprint then it is probably re-using an IP from a previous provision. You must clean up the ~/.ssh/known_hosts file and try to bootstrap it using the above command.

Customizing further

List available base OS Images

  • If you want a different OS, run this command to list all available OSes:
knife digital_ocean image list --public
  • Make note of which image you want to use. We'll be using the Slug name when we create the VM

List available regions

  • If you want a different region. Run this command to list all available regions:
knife digital_ocean region list
  • Once again, you will use the Slug to specify this when creating a VM

List available instance sizes

  • If you want a different sized VM, get a list of available sizes:
knife digital_ocean size list
  • The Slug will again be used here. Please do not use over 512mb unless you ask first! (Its $5/month for 512mb and significantly more for biggest instances)

Sources: