Skip to content

Instantly share code, notes, and snippets.

@raygunsix
Created April 27, 2012 22:53
Show Gist options
  • Save raygunsix/2514066 to your computer and use it in GitHub Desktop.
Save raygunsix/2514066 to your computer and use it in GitHub Desktop.
Base vagrant file for new projects
# Before running vagrant, export the shell variable for the organization on Hosted Chef and
# make sure the validator certificate is in ~/.chef.
# You can optionally export a shell variable for your Chef server username if it is different
# from your OS user export OPSCODE_USER=bofh
user = ENV['OPSCODE_USER'] || ENV['USER']
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu-lucid64"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
# Boot with a GUI so you can see the screen. (Default is headless)
# config.vm.boot_mode = :gui
# Assign this VM to a host only network IP, allowing you to access it
# via the IP.
# config.vm.network "33.33.33.10"
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
config.vm.forward_port 80, 8000
config.vm.forward_port 8080, 8080
# Share an additional folder to the guest VM. The first argument is
# an identifier, the second is the path on the guest to mount the
# folder, and the third is the path on the host to the actual folder.
# config.vm.share_folder "v-data", "/vagrant_data", "../data"
config.vm.customize [
"modifyvm", :id,
"--name", "Vagrant PROJECT NAME VM",
"--memory", "1024"
]
# Chef config
# specify chef gem version
config.vm.provision :shell, :inline => "gem install chef --version 0.10.8 --no-ri --no-rdoc"
config.vm.provision :chef_client do |chef|
# Set up some organization specific values based on environment variable above.
chef.chef_server_url = "https://api.opscode.com/organizations/#{ENV['OPSCODE_ORGNAME']}"
chef.validation_key_path = "#{ENV['HOME']}/.chef/#{ENV['OPSCODE_ORGNAME']}-validator.pem"
chef.validation_client_name = "#{ENV['OPSCODE_ORGNAME']}-validator"
# Change the node/client name for the Chef Server
chef.node_name = "#{user}-vagrant-PROJECT NAME"
# Put the client.rb in /etc/chef so chef-client can be run w/o specifying
chef.provisioning_path = "/etc/chef"
chef.log_level = :info
chef.environment = "development"
chef.add_role("base")
#chef.add_role("")
#chef.add_recipe("")
# Data bag secret
chef.encrypted_data_bag_secret_key_path = "#{ENV['HOME']}/.chef/encrypted_data_bag_secret"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment