Class: VagrantPlugins::Puppet::Provisioner::Puppet

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-windows/monkey_patches/plugins/provisioners/puppet/provisioner/puppet.rb

Instance Method Summary collapse

Instance Method Details

#configure_on_windows(root_config) ⇒ Object



70
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
# File 'lib/vagrant-windows/monkey_patches/plugins/provisioners/puppet/provisioner/puppet.rb', line 70

def configure_on_windows(root_config)
  # Calculate the paths we're going to use based on the environment
  root_path = @machine.env.root_path
  @expanded_manifests_path = @config.expanded_manifests_path(root_path)
  @expanded_module_paths   = @config.expanded_module_paths(root_path)
  @manifest_file           = File.join(manifests_guest_path, @config.manifest_file)

  # Setup the module paths
  @module_paths = []
  @expanded_module_paths.each_with_index do |path, i|
    @module_paths << [path, File.join(config.temp_dir, "modules-#{i}")]
  end

  @logger.debug("Syncing folders from puppet configure")
  @logger.debug("manifests_guest_path = #{manifests_guest_path}")
  @logger.debug("expanded_manifests_path = #{@expanded_manifests_path}")

  # Windows guest volume mounting fails without an "id" specified
  # This hacks around that problem and allows the PS mount script to work
  root_config.vm.synced_folder(
    @expanded_manifests_path, manifests_guest_path,
    :id =>  "v-manifests-1")

  # Share the manifests directory with the guest
  #root_config.vm.synced_folder(
  #  @expanded_manifests_path, manifests_guest_path)

  # Share the module paths
  count = 0
  @module_paths.each do |from, to|
    # Sorry for the cryptic key here, but VirtualBox has a strange limit on
    # maximum size for it and its something small (around 10)
    root_config.vm.synced_folder(from, to, :id => "v-modules-#{count}")
    count += 1
  end
end

#is_windowsObject



107
108
109
# File 'lib/vagrant-windows/monkey_patches/plugins/provisioners/puppet/provisioner/puppet.rb', line 107

def is_windows
  @machine.config.vm.guest.eql? :windows
end

#run_puppet_apply_on_windowsObject



20
21
22
23
24
25
26
27
28
29
30
31
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
68
# File 'lib/vagrant-windows/monkey_patches/plugins/provisioners/puppet/provisioner/puppet.rb', line 20

def run_puppet_apply_on_windows
  options = [config.options].flatten
  module_paths = @module_paths.map { |_, to| to }
  if !@module_paths.empty?
    # Prepend the default module path
    module_paths.unshift("/ProgramData/PuppetLabs/puppet/etc/modules")

    # Add the command line switch to add the module path
    options << "--modulepath '#{module_paths.join(';')}'"
  end

  if @hiera_config_path
    options << "--hiera_config=#{@hiera_config_path}"
  end

  if !@machine.env.ui.is_a?(Vagrant::UI::Colored)
    options << "--color=false"
  end

  options << "--manifestdir #{manifests_guest_path}"
  options << "--detailed-exitcodes"
  options << @manifest_file
  options = options.join(" ")

  # Build up the custom facts if we have any
  facter = ""
  if !config.facter.empty?
    facts = []
    config.facter.each do |key, value|
      facts << "$env:FACTER_#{key}='#{value}';"
    end

    facter = "#{facts.join(" ")} "
  end

  command = "#{facter} puppet apply #{options}"
  if config.working_directory
    command = "cd #{config.working_directory}; if($?) \{ #{command} \}"
  end

  @machine.env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet",
                              :manifest => @manifest_file)

  @machine.communicate.sudo(command) do |type, data|
    if !data.empty?
      @machine.env.ui.info(data, :new_line => false, :prefix => false)
    end
  end
end