Skip to content

Instantly share code, notes, and snippets.

@mountcedar
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mountcedar/912cf65b3405c3966161 to your computer and use it in GitHub Desktop.
Save mountcedar/912cf65b3405c3966161 to your computer and use it in GitHub Desktop.
今さら聞けないVagrantとDigital Oceanで格安VPS運用 ref: http://qiita.com/mountcedar/items/353e615a618ad1fc4ec4
# caskをインストールしていない人はここから
$ brew install caskroom/cask/brew-cask
# インストールしている人はここから
$ brew cask install vagrant virtualbox
$ brew update
$ brew cask install virtualbox
DROPLET_NAME = "vagrant-test"
PRIVATE_KEY_PATH = "~/.ssh/do_secret"
PROVIDER_TOKEN = "<APIタブから作ることのできるトークン番号>"
$ vagrant up --provider=digital_ocean
$ vagrant halt
$ vagrant destroy
$ vagrant digitalocean-list images $DIGITAL_OCEAN_TOKEN
$ vagrant digitalocean-list regions $DIGITAL_OCEAN_TOKEN
$ vagrant digitalocean-list sizes $DIGITAL_OCEAN_TOKEN
Everyone you refer gets $10 in credit. Once they’ve spent $25 with us, you'll get $25. There is no limit to the amount of credit you can earn through referrals.
$ ssh-keygen -t rsa -b 4096 -f ~/.ssh/do_secret
$ ls ~/.ssh/
do_secret # ssh秘密鍵
do_secret.pub # ssh公開鍵
$ chmod 700 ~/.ssh ;
$ chmod 600 ~/.ssh/do_secret ;
$ chmod 644 ~/.ssh/do_secret.pub ;
$ vagrant plugin install dotenv
$ vagrant plugin install vagrant-digitalocean
$ mkdir vm
$ cd vm
$ touch Vagrantfile
$ emacs Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Dotenv.load
# change default provider to digital_ocean
ENV['VAGRANT_DEFAULT_PROVIDER'] = "digital_ocean"
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider :digital_ocean do |provider, override|
override.ssh.private_key_path = "#{ENV['PRIVATE_KEY_PATH']}"
override.vm.hostname = "#{ENV['DROPLET_NAME']}"
override.vm.box = 'digital_ocean'
override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"
provider.token = "#{ENV['PROVIDER_TOKEN']}"
provider.image = 'ubuntu-14-04-x64'
provider.region = 'sgp1'
provider.size = '512mb'
# disable synced_folder: rsync is not installed on DigitalOcean's guest machine
override.vm.synced_folder "./", "/vagrant", disabled: true
# provision
# Do whatever you wanna do !!
# X forward settings
config.ssh.forward_agent = true
config.ssh.forward_x11 = true
end
end
$ touch .env
$ emacs .env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment