provisioners/chef: DRY up `environment` and `node_name` configuration

This commit is contained in:
Teemu Matilainen 2014-02-21 23:28:46 -03:00
parent 116e7aac16
commit 7d90191212
6 changed files with 6 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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