Skip to content

Instantly share code, notes, and snippets.

@tomohiro
Created July 24, 2013 11:22
Show Gist options
  • Save tomohiro/6069748 to your computer and use it in GitHub Desktop.
Save tomohiro/6069748 to your computer and use it in GitHub Desktop.
VirtualBox and EC2 and Puppet settings in the Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# $ vagrant box list
# centos64 (aws)
# centos64 (virtualbox)
#
# VirtualBox:
# $ vagrant up
#
# AWS EC2:
# $ vagrant up --provider=aws
Vagrant.configure('2') do |config|
config.vm.box = 'centos64'
config.vm.hostname = 'my-dev-box'
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 443, host: 4343
config.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID']
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
aws.ami = ENV['AWS_AMI_ID']
aws.region = 'ap-northeast-1'
aws.availability_zone = 'ap-northeast-1c'
aws.instance_type = 't1.micro'
aws.security_groups = ['webserver']
aws.keypair_name = ENV['AWS_KEYPARE_NAME']
override.ssh.username = ENV['AWS_SSH_USERNAME'] || 'ec2-user'
override.ssh.private_key_path = ENV['AWS_SSH_PRIVATE_KEY_PATH']
end
config.vm.provision :puppet do |puppet|
puppet.options = ['--templatedir', '/vagrant/templates']
puppet.facter = {
'user' => ENV['AWS_SSH_USERNAME'] || 'vagrant',
'group' => ENV['AWS_SSH_USERNAME'] || 'vagrant'
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment