# -*- mode: ruby -*- # vi: set ft=ruby : # default box when no VAGRANT_BOX / VAGRANT_BOX_URL environment is set BOX_NAME = "precise64" BOX_URL = "http://files.vagrantup.com/precise64.box" CHEF_CREATE_WORKSTATION = <<-EOF #!/bin/sh [ -f "/vagrant/.chef/chef-validator.pem" ] && { # compare chef-validator.pem file, don't continue when its already the same server_md5=`md5sum /etc/chef-server/chef-validator.pem | cut -f1 -d' '` client_md5=`md5sum /vagrant/.chef/chef-validator.pem | cut -f1 -d' '` [ "$server_md5" = "$client_md5" ] && exit 0 } echo "Creating workstation knife configuration" mkdir -p /vagrant/.chef/checksums cp /etc/chef-server/chef-validator.pem /vagrant/.chef/ cp /etc/chef-server/admin.pem /vagrant/.chef/ EOF require 'vagrant-omnibus' #Vagrant::Config.run do |config| Vagrant.configure('2') do |config| config.vm.box = ENV.fetch("VAGRANT_BOX", BOX_NAME) config.vm.box_url = ENV.fetch("VAGRANT_BOX_URL", BOX_URL) config.omnibus.chef_version = :latest config.hostmanager.enabled = true config.hostmanager.include_offline = true config.vm.provision :hostmanager config.vm.define :chef_server do |v| v.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", 1024] end v.vm.network :private_network, ip: "192.168.33.10" v.vm.hostname = "chefserver.vagrant.local" v.vm.provision :chef_solo do |chef| chef.add_recipe "chef-server::default" end v.vm.provision :shell, :inline => CHEF_CREATE_WORKSTATION end config.vm.define :client do |v| v.vm.network :private_network, ip: "192.168.33.20" v.vm.hostname = "client.vagrant.local" v.vm.provision :chef_client do |chef| chef.chef_server_url = 'https://chefserver.vagrant.local' chef.validation_key_path = ".chef/chef-validator.pem" chef.validation_client_name = "chef-validator" chef.add_recipe "apt" end end end