create a project folder with git
git init my_project
cd my_project
echo /cookbooks >> .gitignore
echo /tmp >> .gitignore
git add .gitignore
git commit -m " ignoring cookbooks & tmp directory created by librarian"
source "https://rubygems.org"
gem "chef"
gem "librarian-chef"
site 'http://community.opscode.com/api/v1'
cookbook 'apt' , '1.7.0'
cookbook 'git' ,
git : 'https://github.com/fnichol/chef-git.git'
cookbook 'rvm' ,
:git => 'https://github.com/fnichol/chef-rvm'
cookbook 'build-essential'
cookbook 'postgresql' ,
:git => 'https://github.com/findsyou/cookbooks' ,
:ref => 'postgresql-improvements'
cookbook 'nginx'
create a role for a runlist
mkdir roles
touch roles/vagrant.rb
name "vagrant"
run_list %w(
recipe[apt]
recipe[build-essential]
recipe[git]
recipe[rvm::vagrant]
recipe[rvm::system]
recipe[postgresql]
recipe[nginx]
)
override_attributes (
"rvm" => {
"default_ruby" => "ruby-1.9.3-p392" ,
"user_default_ruby" => "ruby-1.9.3-p392"
}
)
git add Cheffile
git add Cheffile.lock
git commit -m " I want these particular versions of these particular cookbooks."
Vagrant . configure ( "2" ) do |config |
config . vm . box = "lucid32"
config . vm . box_url = "http://files.vagrantup.com/lucid32.box"
config . vm . network :forwarded_port , guest : 80 , host : 8080
config . vm . network :private_network , ip : "192.168.33.10"
config . vm . provision :chef_solo do |chef |
chef . cookbooks_path = [ "cookbooks" ]
chef . roles_path = "roles"
chef . add_role "vagrant"
end
end