Class: VagrantPlugins::Chef::Provisioner::ChefSolo

Inherits:
Base
  • Object
show all
Includes:
VagrantWindows::Helper
Defined in:
lib/vagrant-windows/monkey_patches/plugins/provisioners/chef/provisioner/chef_solo.rb

Instance Method Summary collapse

Methods included from VagrantWindows::Helper

#wait_if_rebooting, #win_friendly_path, #win_friendly_share_id

Constructor Details

#initialize(machine, config) ⇒ ChefSolo

Returns a new instance of ChefSolo.



13
14
15
16
17
# File 'lib/vagrant-windows/monkey_patches/plugins/provisioners/chef/provisioner/chef_solo.rb', line 13

def initialize(machine, config)
  super
  @windows_machine = VagrantWindows::WindowsMachine.new(machine)
  @logger = Log4r::Logger.new("vagrant::provisioners::chef_solo")
end

Instance Method Details

#run_chef_solo_on_windowsObject

Raises:

  • (ChefError)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/vagrant-windows/monkey_patches/plugins/provisioners/chef/provisioner/chef_solo.rb', line 32

def run_chef_solo_on_windows
  
  #################### START - monkey patched code ####################
  command_builder = ::VagrantWindows::Provisioners::ChefCommandBuilder.new(
    @windows_machine, @config, :solo)
  
  command_builder.prepare_for_chef_run()
  command = command_builder.run_chef_command()
  ###################### END - monkey patched code ####################

  @config.attempts.times do |attempt|
    if attempt == 0
      @machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_solo")
    else
      @machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_solo_again")
    end
    
    #################### START - monkey patched code ####################
    @windows_machine.reinitialize_network_shares()
    ###################### END - monkey patched code ####################

    exit_status = @machine.communicate.execute(command, :error_check => false) do |type, data|
      # Output the data with the proper color based on the stream.
      color = type == :stdout ? :green : :red

      @machine.env.ui.info(
        data, :color => color, :new_line => false, :prefix => false)
    end

    # There is no need to run Chef again if it converges
    return if exit_status == 0
  end

  # If we reached this point then Chef never converged! Error.
  raise ChefError, :no_convergence
end