Method: VagrantPlugins::VagrantHyperV::Provisioner::ChefSolo#setup_config

Defined in:
lib/vagrant-windows-hyperv/provisioner/chef_solo.rb

#setup_config(template, filename, template_vars) ⇒ Object

[View source]

71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/vagrant-windows-hyperv/provisioner/chef_solo.rb', line 71

def setup_config(template, filename, template_vars)
  # If we have custom configuration, upload it
  remote_custom_config_path = nil
  if config.custom_config_path
    expanded = File.expand_path(
      config.custom_config_path, @machine.env.root_path)
    remote_custom_config_path = File.join(
      config.provisioning_path, "custom-config.rb")

    @env[:machine].provider.driver.upload(expanded, remote_custom_config_path)
  end

  config_file = Vagrant::Util::TemplateRenderer.render(template, {
    :custom_configuration => remote_custom_config_path,
    :file_cache_path => config.file_cache_path,
    :file_backup_path => config.file_backup_path,
    :log_level        => config.log_level.to_sym,
    :verbose_logging  => config.verbose_logging,
    :http_proxy       => config.http_proxy,
    :http_proxy_user  => config.http_proxy_user,
    :http_proxy_pass  => config.http_proxy_pass,
    :https_proxy      => config.https_proxy,
    :https_proxy_user => config.https_proxy_user,
    :https_proxy_pass => config.https_proxy_pass,
    :no_proxy         => config.no_proxy,
    :formatter        => config.formatter
  }.merge(template_vars))

  # Create a temporary file to store the data so we
  # can upload it
  temp = Tempfile.new("vagrant")
  temp.write(config_file)
  temp.close

  remote_file = File.join(config.provisioning_path, filename)
  @env[:machine].provider.driver.upload(temp.path, remote_file)
end