From 5f751d5a770efb958cd6ee81a9b8dec07396c007 Mon Sep 17 00:00:00 2001 From: Pat Collins Date: Tue, 10 May 2011 15:48:43 -0400 Subject: [PATCH] Provide a method to specify a Chef environment in a Vagrantfile. --- lib/vagrant/provisioners/chef_server.rb | 5 ++++- templates/chef_server_client.erb | 4 ++++ test/vagrant/provisioners/chef_server_test.rb | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/provisioners/chef_server.rb b/lib/vagrant/provisioners/chef_server.rb index 90699a361..bc6a31853 100644 --- a/lib/vagrant/provisioners/chef_server.rb +++ b/lib/vagrant/provisioners/chef_server.rb @@ -14,6 +14,7 @@ module Vagrant attr_accessor :client_key_path attr_accessor :file_cache_path attr_accessor :file_backup_path + attr_accessor :environment def initialize super @@ -22,6 +23,7 @@ module Vagrant @client_key_path = "/etc/chef/client.pem" @file_cache_path = "/srv/chef/file_store" @file_backup_path = "/srv/chef/cache" + @environment = "_default" end def validate(errors) @@ -71,7 +73,8 @@ module Vagrant :validation_key => guest_validation_key_path, :client_key => config.client_key_path, :file_cache_path => config.file_cache_path, - :file_backup_path => config.file_backup_path + :file_backup_path => config.file_backup_path, + :environment => config.environment }) end diff --git a/templates/chef_server_client.erb b/templates/chef_server_client.erb index a4012a1ff..6b48f6e84 100644 --- a/templates/chef_server_client.erb +++ b/templates/chef_server_client.erb @@ -13,6 +13,10 @@ client_key "<%= client_key %>" file_cache_path "<%= file_cache_path %>" file_backup_path "<%= file_backup_path %>" +<% unless environment == "_default" %> +environment "<%= environment %>" +<% end %> + pid_file "/var/run/chef/chef-client.pid" Mixlib::Log::Formatter.show_time = true diff --git a/test/vagrant/provisioners/chef_server_test.rb b/test/vagrant/provisioners/chef_server_test.rb index bb314087d..0c47b99d6 100644 --- a/test/vagrant/provisioners/chef_server_test.rb +++ b/test/vagrant/provisioners/chef_server_test.rb @@ -161,7 +161,8 @@ class ChefServerProvisionerTest < Test::Unit::TestCase :validation_key => @action.guest_validation_key_path, :client_key => @config.client_key_path, :file_cache_path => @config.file_cache_path, - :file_backup_path => @config.file_backup_path + :file_backup_path => @config.file_backup_path, + :environment => @config.environment }) @action.setup_server_config