Last active
August 29, 2015 14:21
-
-
Save mountcedar/912cf65b3405c3966161 to your computer and use it in GitHub Desktop.
今さら聞けないVagrantとDigital Oceanで格安VPS運用 ref: http://qiita.com/mountcedar/items/353e615a618ad1fc4ec4
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
# caskをインストールしていない人はここから | |
$ brew install caskroom/cask/brew-cask | |
# インストールしている人はここから | |
$ brew cask install vagrant virtualbox |
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
$ brew update | |
$ brew cask install virtualbox |
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
DROPLET_NAME = "vagrant-test" | |
PRIVATE_KEY_PATH = "~/.ssh/do_secret" | |
PROVIDER_TOKEN = "<APIタブから作ることのできるトークン番号>" |
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
$ vagrant up --provider=digital_ocean | |
$ vagrant halt | |
$ vagrant destroy |
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
$ vagrant digitalocean-list images $DIGITAL_OCEAN_TOKEN |
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
$ vagrant digitalocean-list regions $DIGITAL_OCEAN_TOKEN |
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
$ vagrant digitalocean-list sizes $DIGITAL_OCEAN_TOKEN |
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
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. |
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
$ ssh-keygen -t rsa -b 4096 -f ~/.ssh/do_secret |
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
$ ls ~/.ssh/ | |
do_secret # ssh秘密鍵 | |
do_secret.pub # ssh公開鍵 |
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
$ chmod 700 ~/.ssh ; | |
$ chmod 600 ~/.ssh/do_secret ; | |
$ chmod 644 ~/.ssh/do_secret.pub ; |
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
$ vagrant plugin install dotenv | |
$ vagrant plugin install vagrant-digitalocean |
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
$ mkdir vm | |
$ cd vm | |
$ touch Vagrantfile | |
$ emacs Vagrantfile |
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
# -*- 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 |
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
$ touch .env | |
$ emacs .env |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment