forked from hartmantis/clamav-chef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
executable file
·91 lines (79 loc) · 2.35 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require "rubygems"
require "bundler"
task :default => [:cookbook_test, :tailor, :foodcritic, :chefspec]
desc "Run knife cookbook syntax test"
task :cookbook_test do
puts "Running cookbook syntax checks..."
puts %x{knife cookbook test -o .. clamav}
$?.exitstatus == 0 or fail "Cookbook syntax check failed!"
end
desc "Run Tailor lint tests"
task :tailor do
puts "Running Tailor lint tests..."
puts %x{tailor `find . -name '*.rb' -and ! -path '*/\.kitchen/*'`}
$?.exitstatus == 0 or fail "Tailor lint tests failed!"
end
desc "Run Foodcritic lint tests"
task :foodcritic do
puts "Running FoodCritic lint tests..."
puts %x{foodcritic -f any .}
$?.exitstatus == 0 or fail "Foodcritic lint tests failed!"
end
desc "Run ChefSpec unit tests"
task :chefspec do
puts "Running ChefSpec unit tests..."
puts %x{rspec}
$?.exitstatus == 0 or fail "ChefSpec unit tests failed!"
end
desc "Run a full converge test"
task :converge do
puts "Running Convergence tests..."
solo_rb = <<-EOH.gsub(/^ +/, "")
file_cache_path "/tmp"
cookbook_path [
"#{File.expand_path("../", __FILE__)}",
"/tmp/berkshelf"
]
role_path nil
log_level :info
encrypted_data_bag_secret "/tmp/encrypted_data_bag_secret"
http_proxy nil
http_proxy_user nil
http_proxy_pass nil
https_proxy nil
https_proxy_user nil
https_proxy_pass nil
no_proxy_nil
EOH
dna_json = <<-EOH.gsub(/^ +/, "")
{
"run_list": [
"recipe[minitest-handler]",
"recipe[clamav::default]",
"recipe[clamav::install_deb]",
"recipe[clamav::users]",
"recipe[clamav::logging]",
"recipe[clamav::clamd]",
"recipe[clamav::freshclam]",
"recipe[clamav::clamd_service]",
"recipe[clamav::freshclam_service]"
],
"clamav": {
"clamd": {
"enabled": true
},
"freshclam": {
"enabled": true
}
}
}
EOH
File.open("/tmp/solo.rb", "w") { |f| f.write(solo_rb) }
File.open("/tmp/dna.json", "w") { |f| f.write(dna_json) }
puts %x{curl -L https://www.opscode.com/chef/install.sh | sudo bash}
puts %x{sudo chef-solo -c /tmp/solo.rb -j /tmp/dna.json}
$?.exitstatus == 0 or fail "Convergence failed!"
puts %x{cucumber test/features}
$?.exitstatus == 0 or fail "Cucumber tests failed!"
end
# vim: ai et ts=2 sts=2 sw=2 ft=ruby fdm=marker