Last active
December 21, 2015 18:59
-
-
Save pesblog/6351515 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
#!/bin/sh | |
# usage: | |
# $ curl -O https://gist.github.com/pesblog/6351515/raw/vagrant-setup.sh | |
# $ chmod 755 vagrant-setup.sh | |
# $ ./vagrant-setup.sh | |
finally() { | |
RET=$? | |
cat <<EOF | |
#--------------------------------------------------------- | |
# Vagrantfile template for aws and local centos | |
#--------------------------------------------------------- | |
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.define :local do |local| | |
local.vm.box = "centos" | |
end | |
config.vm.define :remote do |remote| | |
remote.vm.box = "dummy" | |
remote.vm.provider :aws do |aws, override| | |
aws.access_key_id = "AWS_ACCESS_KEY_ID" | |
aws.secret_access_key = "AWS_SECRET_ACCESS_KEY" | |
aws.keypair_name = "KEY_NAME" | |
aws.instance_type = "t1.micro" | |
aws.region = "ap-northeast-1" | |
aws.ami = "ami-00000000" | |
aws.security_groups = [ 'ec2-user' ] | |
aws.tags = { | |
"Name" => "VAGRANT_TEST" | |
} | |
override.ssh.username = "ec2-user" | |
override.ssh.private_key_path = "~/.ssh/VAGRANT.pem" | |
end | |
end | |
end | |
#--------------------------------------------------------- | |
# usege: | |
# vagrant up local | |
# vagrant up remote --provider=aws | |
#--------------------------------------------------------- | |
EOF | |
exit $RET | |
} | |
set -e | |
trap finally EXIT | |
if [[ `which vagrant` ]]; then | |
echo "vagrant exists, already installed. finish" | |
exit 0 | |
fi | |
tmp_dir='/tmp/vagrant-setup' | |
mkdir $tmp_dir | |
cd $tmp_dir | |
curl -O http://files.vagrantup.com/packages/7ec0ee1d00a916f80b109a298bab08e391945243/Vagrant-1.2.7.dmg | |
open Vagrant-1.2.7.dmg | |
echo "vagrant install done?> " | |
read INPUT | |
rm -rf $tmp_dir | |
cd - | |
echo "Installing vagrant-sahara plugin" | |
vagrant plugin install sahara | |
echo "Installing vagrant-aws plugin" | |
vagrant plugin install vagrant-aws | |
echo "Installing dummy box" | |
vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box | |
echo "Installing CentOS 6.3 x86_64 + Chef 10.14.2 + VirtualBox 4.1.22 (with guest additions)" | |
vagrant box add centos https://s3.amazonaws.com/itmat-public/centos-6.3-chef-10.14.2.box | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment