Class: Vagrant::ChefConfig::ChefClientConfigurator

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-chefconfig/chef_client_configurator.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ ChefClientConfigurator

Returns a new instance of ChefClientConfigurator.



9
10
11
12
# File 'lib/vagrant-chefconfig/chef_client_configurator.rb', line 9

def initialize(env)
  @logger = Log4r::Logger.new("vagrant_chefconfig::chefclientconfigurator") 
  @env = env
end

Instance Method Details

#apply_knife_configObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-chefconfig/chef_client_configurator.rb', line 14

def apply_knife_config()
  provisioners = chef_client_provisioners
  return if provisioners.length == 0

  load_knife_config()

  provisioners.each do |provisioner|
    chef_config = provisioner.config

    #                           vagrant config key                   knife config key
    set_if_default(chef_config, :chef_server_url,                    :chef_server_url)
    set_if_default(chef_config, :log_level,                          :log_level)
    set_if_default(chef_config, :validation_key_path,                :validation_key)
    set_if_default(chef_config, :validation_client_name,             :validation_client_name)
    set_if_default(chef_config, :environment,                        :vagrant_environment)
    set_if_default(chef_config, :encrypted_data_bag_secret_key_path, :encrypted_data_bag_secret)
  end
end