Class: Vagrant::Provisioners::Puppet

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

Instance Method Summary collapse

Instance Method Details

#run_puppet_clientObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vagrant-windows/provisioners/puppet.rb', line 4

def run_puppet_client
    options = [config.options].flatten
    if env[:vm].config.vm.guest == :windows
    	options << "--modulepath '#{@module_paths.values.join(';')}'" if !@module_paths.empty?
    else
    	options << "--modulepath '#{@module_paths.values.join(':')}'" if !@module_paths.empty?
    end
    
    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|
      	if env[:vm].config.vm.guest == :windows
      		facts << "$env:FACTER_#{key}='#{value}';"
					else
        	facts << "FACTER_#{key}='#{value}'"
        end
      end
					
    	facter = "#{facts.join(" ")} "
    end
    if env[:vm].config.vm.guest == :windows
    	command = "cd #{manifests_guest_path}; if($?) \{ #{facter} puppet apply #{options} \}"
    else
    	command = "cd #{manifests_guest_path} && #{facter}puppet apply #{options}"
    end

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

    env[:vm].channel.sudo(command) do |type, data|
      env[:ui].info(data.chomp, :prefix => false)
    end
end

#verify_binary(binary) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vagrant-windows/provisioners/puppet.rb', line 42

def verify_binary(binary)
			  if env[:vm].config.vm.guest == :windows
command = "command #{binary}"
		      else
command = "which #{binary}"
		      end
  env[:vm].channel.sudo(command,
                      :error_class => PuppetError,
                      :error_key => :not_detected,
                      :binary => binary)
end

#verify_shared_folders(folders) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vagrant-windows/provisioners/puppet.rb', line 53

def verify_shared_folders(folders)
  folders.each do |folder|
    @logger.debug("Checking for shared folder: #{folder}")

    
    if env[:vm].config.vm.guest == :windows
  	if !env[:vm].channel.test("if(-not (test-path #{folder})) \{exit 1\} ")
      	raise PuppetError, :missing_shared_folders
    	end
 else
  	if !env[:vm].channel.test("test -d #{folder}")
    			raise PuppetError, :missing_shared_folders
 			end
 end

  end
end