forked from voxpupuli/puppet-staging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
51 lines (44 loc) · 1.3 KB
/
Rakefile
1
2
3
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
42
43
44
45
46
47
48
49
50
51
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'
def io_popen(command)
IO.popen(command) do |io|
io.each do |line|
print line
yield line if block_given?
end
end
end
# Customize lint option
task :lint do
PuppetLint.configuration.send("disable_80chars")
PuppetLint.configuration.send("disable_class_parameter_defaults")
end
desc "Validate manifests, templates, and ruby files in lib."
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['lib/**/*.rb'].each do |lib_file|
sh "ruby -c #{lib_file}"
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
# Initialize vagrant instance for testing
desc "Powers on Vagrant VMs with specific manifests"
task :vagrant, :manifest do |t, args|
Rake::Task["spec_prep"].execute
prefix = "VAGRANT_MANIFEST='#{args[:manifest]||'init.pp'}'"
puts args[:manifest]
provision = false
io_popen("export #{prefix}; vagrant up --provider=vmware_fusion") do |line|
provision = true if line =~ /Machine is already running./
end
io_popen("export #{prefix}; vagrant provision") if provision
end
# Cleanup vagrant environment
task :vagrant_clean do
`vagrant destroy -f`
Rake::Task["spec_clean"].execute
end