http://luuuc.github.io/vagrant-chef-server
You need the following.
- virtualbox (https://www.virtualbox.org)
- The latest VirtualBox platform packages.
- The latest VirtualBox Extension Pack.
- ruby (https://www.ruby-lang.org)
- I'm using version 2.0.0-p247 with rbenv/ruby-build (installed via homebrew)
- You have a great installation tutorial at https://github.com/sstephenson/rbenv#installation
- Chef (http://www.opscode.com)
- You have a great installation tutorial at https://learnchef.opscode.com/quickstart/workstation-setup/
-
Vagrant (http://www.vagrantup.com)
-
Omnibus Vagrant plugin (https://github.com/schisamo/vagrant-omnibus)
- In you terminal issue the command
vagrant plugin install vagrant-omnibus
- Berkshelf Vagrant plugin (https://github.com/riotgames/vagrant-berkshelf)
- In you terminal issue the command
vagrant plugin install vagrant-berkshelf
First clone this repository then
$ bundle install --path vendor
$ berks install --path cookbooks
$ vagrant up
Visit https://10.33.33.33/version to check if everything is working. Then https://10.33.33.33 to access the web interface (admin/p@ssw0rd1). Change to a secure password and regenerate certificates.
Create and move to the project folder.
$ mkdir vagrant-chef-server
$ cd vagrant-chef-server
Create a gem file.
$ cat > Gemfile <<EOF
source "https://rubygems.org"
gem "knife-solo"
gem "berkshelf"
EOF
Install the gem locally to a new 'vendor' folder.
$ bundle install --path vendor
Create a knife solo (a.k.a chef solo) folder structure.
$ knife solo init .
Create a Berkshelf file to manage cookbooks.
$ cat > Berksfile <<EOF
site :opscode
cookbook 'chef-server'
EOF
Install Berkshelf cookbooks.
$ berks install --path cookbooks
Create “chef.json” file in the role folder with the following content.
{
"name": "chef",
"chef_type": "role",
"json_class": "Chef::Role",
"description": "The base role for Chef Server",
"default_attributes": {
"chef-server": {
"version": "latest",
"configuration": {
"chef_server_webui": {
"enable": true
}
}
}
},
"run_list": [
"recipe[chef-server::default]"
]
}
You can change or find more info to the above settings at https://github.com/opscode-cookbooks/chef-server/blob/master/attributes/default.rb
Done !
Create a vagrant intialization file with the following command.
vagrant init
Change your vagrant to file to:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "10.33.33.33"
config.vm.network :forwarded_port, guest: 80, host: 8000
config.vm.network :forwarded_port, guest: 443, host: 8443
config.vm.provider :virtualbox do |v|
v.name = "chef-server"
v.customize ["modifyvm", :id, "--cpus", "2"]
v.customize ["modifyvm", :id, "--memory", "1024"]
end
config.omnibus.chef_version = :latest
config.berkshelf.enabled = true
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.roles_path = "roles"
chef.data_bags_path = "data_bags"
chef.add_role("chef")
end
end
Launch the virtual machines.
$ vagrant up
Visit https://10.33.33.33/version to check if everything is working. Then https://10.33.33.33 to access the web interface (admin/p@ssw0rd1). Change to a secure password and regenerate certificates.
You can access your chef server from another computer in the same network with https://your-machine-ip:8443
Connect through ssh to copy your chef server keys.
$ vagrant ssh chef
vagrant@precise64:~$ sudo cp /etc/chef-server/*.pem /vagrant/.chef/
Configure knife
$ knife configure -i
- chef server URL: https://10.33.33.33
- clientname: admin
- admin client's private key: .chef/webui.pem
- validation key: .chef/validation.pem
Check knife configuration:
$ knife client list
> chef-validator
> chef-webui
That's it! You're now ready to cook.