From 7d901912127a86739eecc5feb915d5dcfe2ab0a0 Mon Sep 17 00:00:00 2001 From: Teemu Matilainen Date: Fri, 21 Feb 2014 23:28:46 -0300 Subject: [PATCH] provisioners/chef: DRY up `environment` and `node_name` configuration --- plugins/provisioners/chef/config/base.rb | 3 +++ plugins/provisioners/chef/config/chef_client.rb | 3 --- plugins/provisioners/chef/config/chef_solo.rb | 3 --- plugins/provisioners/chef/provisioner/base.rb | 4 +++- plugins/provisioners/chef/provisioner/chef_client.rb | 2 -- plugins/provisioners/chef/provisioner/chef_solo.rb | 2 -- 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/plugins/provisioners/chef/config/base.rb b/plugins/provisioners/chef/config/base.rb index 532372ed4..ae63a4522 100644 --- a/plugins/provisioners/chef/config/base.rb +++ b/plugins/provisioners/chef/config/base.rb @@ -12,6 +12,7 @@ module VagrantPlugins attr_accessor :binary_env attr_accessor :custom_config_path attr_accessor :encrypted_data_bag_secret_key_path + attr_accessor :environment attr_accessor :formatter attr_accessor :http_proxy attr_accessor :http_proxy_user @@ -38,6 +39,7 @@ module VagrantPlugins @binary_env = UNSET_VALUE @custom_config_path = UNSET_VALUE @encrypted_data_bag_secret_key_path = UNSET_VALUE + @environment = UNSET_VALUE @formatter = UNSET_VALUE @http_proxy = UNSET_VALUE @http_proxy_user = UNSET_VALUE @@ -69,6 +71,7 @@ module VagrantPlugins @binary_path = nil if @binary_path == UNSET_VALUE @binary_env = nil if @binary_env == UNSET_VALUE @custom_config_path = nil if @custom_config_path == UNSET_VALUE + @environment = nil if @environment == UNSET_VALUE @formatter = nil if @formatter == UNSET_VALUE @http_proxy = nil if @http_proxy == UNSET_VALUE @http_proxy_user = nil if @http_proxy_user == UNSET_VALUE diff --git a/plugins/provisioners/chef/config/chef_client.rb b/plugins/provisioners/chef/config/chef_client.rb index c009064d5..9684d2b0e 100644 --- a/plugins/provisioners/chef/config/chef_client.rb +++ b/plugins/provisioners/chef/config/chef_client.rb @@ -10,7 +10,6 @@ module VagrantPlugins attr_accessor :client_key_path attr_accessor :delete_client attr_accessor :delete_node - attr_accessor :environment attr_accessor :validation_key_path attr_accessor :validation_client_name @@ -21,7 +20,6 @@ module VagrantPlugins @client_key_path = UNSET_VALUE @delete_client = UNSET_VALUE @delete_node = UNSET_VALUE - @environment = UNSET_VALUE @validation_key_path = UNSET_VALUE @validation_client_name = UNSET_VALUE end @@ -33,7 +31,6 @@ module VagrantPlugins @client_key_path = "/etc/chef/client.pem" if @client_key_path == UNSET_VALUE @delete_client = false if @delete_client == UNSET_VALUE @delete_node = false if @delete_node == UNSET_VALUE - @environment = nil if @environment == UNSET_VALUE @validation_client_name = "chef-validator" if @validation_client_name == UNSET_VALUE @validation_key_path = nil if @validation_key_path == UNSET_VALUE end diff --git a/plugins/provisioners/chef/config/chef_solo.rb b/plugins/provisioners/chef/config/chef_solo.rb index 6142f2269..59c3b858e 100644 --- a/plugins/provisioners/chef/config/chef_solo.rb +++ b/plugins/provisioners/chef/config/chef_solo.rb @@ -7,7 +7,6 @@ module VagrantPlugins attr_accessor :cookbooks_path attr_accessor :data_bags_path attr_accessor :environments_path - attr_accessor :environment attr_accessor :recipe_url attr_accessor :roles_path attr_accessor :synced_folder_type @@ -18,7 +17,6 @@ module VagrantPlugins @cookbooks_path = UNSET_VALUE @data_bags_path = UNSET_VALUE @environments_path = UNSET_VALUE - @environment = UNSET_VALUE @recipe_url = UNSET_VALUE @roles_path = UNSET_VALUE @synced_folder_type = UNSET_VALUE @@ -43,7 +41,6 @@ module VagrantPlugins def finalize! super - @environment = nil if @environment == UNSET_VALUE @recipe_url = nil if @recipe_url == UNSET_VALUE @synced_folder_type = nil if @synced_folder_type == UNSET_VALUE diff --git a/plugins/provisioners/chef/provisioner/base.rb b/plugins/provisioners/chef/provisioner/base.rb index 6243eb927..4be66f346 100644 --- a/plugins/provisioners/chef/provisioner/base.rb +++ b/plugins/provisioners/chef/provisioner/base.rb @@ -58,9 +58,11 @@ module VagrantPlugins config_file = Vagrant::Util::TemplateRenderer.render(template, { :custom_configuration => remote_custom_config_path, :encrypted_data_bag_secret => guest_encrypted_data_bag_secret_key_path, - :file_cache_path => @config.file_cache_path, + :environment => @config.environment, + :file_cache_path => @config.file_cache_path, :file_backup_path => @config.file_backup_path, :log_level => @config.log_level.to_sym, + :node_name => @config.node_name, :verbose_logging => @config.verbose_logging, :http_proxy => @config.http_proxy, :http_proxy_user => @config.http_proxy_user, diff --git a/plugins/provisioners/chef/provisioner/chef_client.rb b/plugins/provisioners/chef/provisioner/chef_client.rb index 084e39458..2e5f07b64 100644 --- a/plugins/provisioners/chef/provisioner/chef_client.rb +++ b/plugins/provisioners/chef/provisioner/chef_client.rb @@ -46,12 +46,10 @@ module VagrantPlugins def setup_server_config setup_config("provisioners/chef_client/client", "client.rb", { - :node_name => @config.node_name, :chef_server_url => @config.chef_server_url, :validation_client_name => @config.validation_client_name, :validation_key => guest_validation_key_path, :client_key => @config.client_key_path, - :environment => @config.environment, }) end diff --git a/plugins/provisioners/chef/provisioner/chef_solo.rb b/plugins/provisioners/chef/provisioner/chef_solo.rb index 2bffe04bf..7f9e304ac 100644 --- a/plugins/provisioners/chef/provisioner/chef_solo.rb +++ b/plugins/provisioners/chef/provisioner/chef_solo.rb @@ -121,13 +121,11 @@ module VagrantPlugins data_bags_path = guest_paths(@data_bags_folders).first environments_path = guest_paths(@environments_folders).first setup_config("provisioners/chef_solo/solo", "solo.rb", { - :node_name => @config.node_name, :cookbooks_path => cookbooks_path, :recipe_url => @config.recipe_url, :roles_path => roles_path, :data_bags_path => data_bags_path, :environments_path => environments_path, - :environment => @config.environment, }) end