puppet-retrospec 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -0
- data/CHANGELOG.md +11 -0
- data/DEVELOPMENT.md +3 -0
- data/Gemfile +10 -9
- data/Gemfile.lock +2 -0
- data/README.md +211 -273
- data/Rakefile +8 -8
- data/VERSION +1 -1
- data/lib/retrospec-puppet.rb +3 -3
- data/lib/retrospec/plugins/v1/plugin/conditional.rb +5 -6
- data/lib/retrospec/plugins/v1/plugin/exceptions.rb +17 -0
- data/lib/retrospec/plugins/v1/plugin/generators.rb +7 -0
- data/lib/retrospec/plugins/v1/plugin/generators/fact_generator.rb +18 -10
- data/lib/retrospec/plugins/v1/plugin/generators/function_generator.rb +187 -0
- data/lib/retrospec/plugins/v1/plugin/generators/module_generator.rb +25 -26
- data/lib/retrospec/plugins/v1/plugin/generators/{facter.rb → parsers/facter.rb} +28 -35
- data/lib/retrospec/plugins/v1/plugin/generators/parsers/function.rb +91 -0
- data/lib/retrospec/plugins/v1/plugin/generators/parsers/type.rb +79 -0
- data/lib/retrospec/plugins/v1/plugin/generators/provider_generator.rb +107 -0
- data/lib/retrospec/plugins/v1/plugin/generators/schema_generator.rb +221 -0
- data/lib/retrospec/plugins/v1/plugin/generators/type_generator.rb +118 -0
- data/lib/retrospec/plugins/v1/plugin/helpers.rb +3 -7
- data/lib/retrospec/plugins/v1/plugin/puppet.rb +141 -60
- data/lib/retrospec/plugins/v1/plugin/puppet_module.rb +29 -26
- data/lib/retrospec/plugins/v1/plugin/resource.rb +6 -7
- data/lib/retrospec/plugins/v1/plugin/spec_object.rb +5 -8
- data/lib/retrospec/plugins/v1/plugin/template_helpers.rb +9 -10
- data/lib/retrospec/plugins/v1/plugin/templates/clone-hook +15 -8
- data/lib/retrospec/plugins/v1/plugin/type_code.rb +4 -4
- data/lib/retrospec/plugins/v1/plugin/variable_store.rb +26 -30
- data/lib/retrospec/plugins/v1/plugin/version.rb +1 -1
- data/puppet-retrospec.gemspec +43 -4
- data/spec/fixtures/facts/oracle_controls.rb +38 -0
- data/spec/fixtures/fixture_modules/required_parameters/manifests/init.pp +8 -0
- data/spec/fixtures/fixture_modules/sample_module/lib/facter/fix_installed.rb +11 -0
- data/spec/fixtures/fixture_modules/sample_module/lib/puppet/functions/awesome_parser.rb +13 -0
- data/spec/fixtures/fixture_modules/sample_module/lib/puppet/functions/reduce.rb +31 -0
- data/spec/fixtures/fixture_modules/sample_module/lib/puppet/parser/functions/bad_sha1.rb +6 -0
- data/spec/fixtures/fixture_modules/sample_module/lib/puppet/parser/functions/defined.rb +94 -0
- data/spec/fixtures/fixture_modules/sample_module/lib/puppet/parser/functions/sha1.rb +6 -0
- data/spec/fixtures/fixture_modules/sample_module/spec/unit/facter/fix_installed_spec.rb +21 -0
- data/spec/fixtures/modules/tomcat/files/.gitkeep +0 -0
- data/spec/fixtures/modules/tomcat/templates/.gitkeep +0 -0
- data/spec/fixtures/modules/tomcat/tests/.gitkeep +0 -0
- data/spec/fixtures/providers/bmc/ipmitool.rb +188 -0
- data/spec/fixtures/providers/bmcuser/ipmitool.rb +140 -0
- data/spec/fixtures/types/bmc.rb +102 -0
- data/spec/fixtures/types/bmcuser.rb +46 -0
- data/spec/fixtures/types/db_opatch.rb +93 -0
- data/spec/integration/retrospec_spec.rb +1 -3
- data/spec/spec_helper.rb +33 -6
- data/spec/unit/conditional_spec.rb +12 -15
- data/spec/unit/generators/fact_generater_spec.rb +49 -17
- data/spec/unit/generators/function_generator_spec.rb +301 -0
- data/spec/unit/generators/function_spec.rb +67 -0
- data/spec/unit/generators/parsers/fact_spec.rb +62 -0
- data/spec/unit/generators/parsers/provider_spec.rb +44 -0
- data/spec/unit/generators/parsers/type_spec.rb +93 -0
- data/spec/unit/generators/provider_generator_spec.rb +120 -0
- data/spec/unit/generators/schema_generator_spec.rb +122 -0
- data/spec/unit/generators/type_generator_spec.rb +173 -0
- data/spec/unit/module_spec.rb +7 -10
- data/spec/unit/plugin_spec.rb +213 -15
- data/spec/unit/puppet-retrospec_spec.rb +81 -100
- data/spec/unit/resource_spec.rb +16 -17
- data/spec/unit/spec_object_spec.rb +46 -0
- data/spec/unit/type_code_spec.rb +9 -11
- data/spec/unit/variable_store_spec.rb +41 -43
- metadata +54 -4
- data/spec/unit/generators/fact_spec.rb +0 -58
@@ -0,0 +1,140 @@
|
|
1
|
+
Puppet::Type.type(:bmcuser).provide(:ipmitool) do
|
2
|
+
desc "Provides ipmitool support for the bmc type"
|
3
|
+
|
4
|
+
commands :ipmitoolcmd => 'ipmitool'
|
5
|
+
# if the open ipmi driver does not exist we can perform any of these configurations
|
6
|
+
# check to see that openipmi driver is loaded and ipmi device exists
|
7
|
+
confine :bmc_device_present => [:true, true]
|
8
|
+
|
9
|
+
mk_resource_methods
|
10
|
+
|
11
|
+
CHANNEL_LOOKUP = {
|
12
|
+
'Dell Inc.' => '1',
|
13
|
+
'FUJITSU' => '2',
|
14
|
+
'FUJITSU SIEMENS' => '2',
|
15
|
+
'HP' => '2',
|
16
|
+
'Intel Corporation' => '3',
|
17
|
+
}
|
18
|
+
PRIV = {
|
19
|
+
:ADMINISTRATOR => 4,
|
20
|
+
:ADMIN => 4,
|
21
|
+
:USER => 2,
|
22
|
+
:CALLBACK => 1,
|
23
|
+
:OPERATOR => 3,
|
24
|
+
:NOACCESS => 15,
|
25
|
+
}
|
26
|
+
|
27
|
+
def initialize(value={})
|
28
|
+
super(value)
|
29
|
+
@property_flush = {}
|
30
|
+
end
|
31
|
+
|
32
|
+
def create
|
33
|
+
set_username resource[:username]
|
34
|
+
set_userpass resource[:userpass]
|
35
|
+
set_privlevel PRIV[resource[:privlevel]]
|
36
|
+
set_enable id # finds an unused id
|
37
|
+
end
|
38
|
+
|
39
|
+
# get the user id supplied by the resource or find out the current user id
|
40
|
+
# if a user id cannot be found, try and create a new user id by looking for empty slots
|
41
|
+
def id
|
42
|
+
@id ||= @property_hash[:id] || user_id(resource[:username])
|
43
|
+
end
|
44
|
+
|
45
|
+
def destroy
|
46
|
+
set_username '(Empty User)'
|
47
|
+
set_privlevel PRIV[:NOACCESS]
|
48
|
+
set_disable id
|
49
|
+
end
|
50
|
+
|
51
|
+
def exists?
|
52
|
+
@property_hash[:ensure] == :present
|
53
|
+
end
|
54
|
+
|
55
|
+
def set_username(value)
|
56
|
+
ipmitoolcmd([ "user", "set", "name", id, value] )
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_userpass(value)
|
60
|
+
ipmitoolcmd([ "user", "set", "password", id, value ])
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
def set_privlevel(value)
|
65
|
+
ipmitoolcmd([ "user", "priv", id, value, channel ])
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def set_enable(value)
|
70
|
+
ipmitoolcmd([ "user", "enable", value ])
|
71
|
+
end
|
72
|
+
|
73
|
+
def set_disable(value)
|
74
|
+
ipmitoolcmd([ "user", "disable", value ])
|
75
|
+
end
|
76
|
+
|
77
|
+
def users
|
78
|
+
unless @users
|
79
|
+
userdata = ipmitoolcmd([ "user", "list", CHANNEL_LOOKUP.fetch(Facter.value(:manufacturer), '1')])
|
80
|
+
@users = []
|
81
|
+
userdata.lines.each do | line|
|
82
|
+
# skip the header
|
83
|
+
next if line.match(/^ID/)
|
84
|
+
id, name, callin, linkauth, enabled, priv = line.chomp.split(' ', 6)
|
85
|
+
# create the resource
|
86
|
+
users << {:name => name, :username => name, :id => id, :enabled => enabled,
|
87
|
+
:callin => callin, :linkauth => linkauth , :privlevel => priv, :userpass => '**Not*Available****' }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
@users
|
91
|
+
end
|
92
|
+
|
93
|
+
def new_user_id
|
94
|
+
begin
|
95
|
+
user = users.find {|user| user[:name] =~ /Empty/i } || users.find {|user| !user[:enabled] }
|
96
|
+
user[:id]
|
97
|
+
rescue
|
98
|
+
fail('Cannot allocate a user id, all ipmi users are taken already')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def user_id(user)
|
103
|
+
if ! found_user = users.find {|u| u[:name] == user }
|
104
|
+
new_user_id
|
105
|
+
else
|
106
|
+
found_user[:id]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.instances
|
111
|
+
userdata = ipmitoolcmd([ "user", "list", CHANNEL_LOOKUP.fetch(Facter.value(:manufacturer), '1')])
|
112
|
+
users = []
|
113
|
+
userdata.lines.each do | line|
|
114
|
+
# skip the header
|
115
|
+
next if line.match(/^ID/)
|
116
|
+
next if line.match(/Empty/i)
|
117
|
+
id, name, callin, linkauth, enabled, priv = line.chomp.split(' ', 6)
|
118
|
+
# create the resource
|
119
|
+
users << new(:name => name, :username => name, :id => id, :ensure => :present,
|
120
|
+
:privlevel => priv, :userpass => '**Hidden**' )
|
121
|
+
end
|
122
|
+
users
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.prefetch(resources)
|
126
|
+
users = instances
|
127
|
+
if users
|
128
|
+
resources.keys.each do | name|
|
129
|
+
if provider = users.find{|user| user.username == name }
|
130
|
+
resources[name].provider = provider
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def channel
|
137
|
+
CHANNEL_LOOKUP.fetch(Facter.value(:manufacturer), '1')
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
@@ -0,0 +1,102 @@
|
|
1
|
+
Puppet::Type.newtype(:bmc) do
|
2
|
+
@doc = "Manage BMC devices"
|
3
|
+
|
4
|
+
ensurable do
|
5
|
+
newvalue(:present) do
|
6
|
+
provider.install
|
7
|
+
end
|
8
|
+
|
9
|
+
newvalue(:absent) do
|
10
|
+
provider.remove
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
newparam(:name, :namevar=>true) do
|
15
|
+
desc "The name of the bmc device."
|
16
|
+
end
|
17
|
+
|
18
|
+
# This is just a simple verification to valid ip related sources
|
19
|
+
def validaddr?(source)
|
20
|
+
valid = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/.match("#{source}")
|
21
|
+
! valid.nil?
|
22
|
+
|
23
|
+
end
|
24
|
+
#
|
25
|
+
# defaultto do
|
26
|
+
#
|
27
|
+
# provider = resource[:provider].downcase
|
28
|
+
# if provider =~ /freeipmi|impitool/
|
29
|
+
# # check to see that openipmi driver is loaded and ipmi device exists
|
30
|
+
# opendriver = File.exists?('/dev/ipmi0') || File.exists?('/dev/ipmi/0') || File.exists?('/dev/ipmidev/0')
|
31
|
+
# if not opendriver
|
32
|
+
# raise ArgumentError , "The openipmi driver cannot be found, is openipmi installed and loaded correctly?"
|
33
|
+
# end
|
34
|
+
# :ipmitool
|
35
|
+
# elsif provider == "oem"
|
36
|
+
# case $manufacturer.downcase!
|
37
|
+
# when "hp", "hewlett packard"
|
38
|
+
# # check if hp's ilo driver is installed
|
39
|
+
# if not File.exists?('/dev/hpilo/dXccbN')
|
40
|
+
# raise ArgumentError , "The hp ilo driver cannot be found, is the ilo driver installed and loaded?"
|
41
|
+
# else
|
42
|
+
# return :hp
|
43
|
+
# end
|
44
|
+
# else
|
45
|
+
# raise ArgumentError , "The manufacturer \"#{$manufacturer}\" is currently not
|
46
|
+
# supported under the oem provider, please try freeipmi or ipmitool"
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
#end
|
52
|
+
|
53
|
+
|
54
|
+
newproperty(:ipsource) do
|
55
|
+
desc "The type of ip address to use static or dhcp"
|
56
|
+
newvalues(:static, :dhcp)
|
57
|
+
defaultto{:dhcp}
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
newproperty(:ip) do
|
62
|
+
desc "The ip address of the bmc device"
|
63
|
+
validate do |value|
|
64
|
+
valid = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/.match("#{value}")
|
65
|
+
if valid.nil?
|
66
|
+
raise ArgumentError , "%s is not a valid ip" % value
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
newproperty(:netmask) do
|
72
|
+
desc "The netmask address of the bmc device"
|
73
|
+
validate do |value|
|
74
|
+
valid = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/.match("#{value}")
|
75
|
+
if valid.nil?
|
76
|
+
raise ArgumentError , "%s is not a valid netmask" % value
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
newproperty(:gateway) do
|
82
|
+
desc "The gateway address of the bmc device"
|
83
|
+
validate do |value|
|
84
|
+
valid = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/.match("#{value}")
|
85
|
+
if valid.nil?
|
86
|
+
raise ArgumentError , "%s is not a valid gateway" % value
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
newproperty(:vlanid) do
|
92
|
+
defaultto {"off"}
|
93
|
+
validate do |value|
|
94
|
+
unless (1..4094).include?(value.to_i) or value == "off"
|
95
|
+
raise ArgumentError , "%s is not a valid vlan id, must be 1-4094" % value
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Puppet::Type.newtype(:bmcuser) do
|
2
|
+
@doc = "Manage BMC devices"
|
3
|
+
|
4
|
+
|
5
|
+
ensurable do
|
6
|
+
newvalue(:present) do
|
7
|
+
provider.create
|
8
|
+
end
|
9
|
+
|
10
|
+
newvalue(:absent) do
|
11
|
+
provider.destroy
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
newproperty(:id) do
|
16
|
+
desc 'The id of the user, gathered from the bmc user list'
|
17
|
+
end
|
18
|
+
|
19
|
+
newparam(:name) do
|
20
|
+
desc 'The name of the resource'
|
21
|
+
end
|
22
|
+
|
23
|
+
newproperty(:username, :namevar => true) do
|
24
|
+
desc "The username to be added"
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
newproperty(:userpass) do
|
29
|
+
desc "The password of the user to create"
|
30
|
+
def change_to_s(current, desire)
|
31
|
+
"userpass is different, changing to specified password"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
newparam(:force) do
|
36
|
+
desc "The force parameter will set the password of the user with every puppet run"
|
37
|
+
newvalues(true, false)
|
38
|
+
end
|
39
|
+
|
40
|
+
newproperty(:privlevel) do
|
41
|
+
desc "The privilege level type for the user"
|
42
|
+
defaultto :ADMIN
|
43
|
+
newvalues(:ADMIN, :USER, :OPERATOR, :CALLBACK, :ADMINISTRATOR, :NOACCESS)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
Puppet::Type.newtype(:db_opatch) do
|
2
|
+
desc 'This is the Oracle Patch process called OPatch'
|
3
|
+
|
4
|
+
newproperty(:ensure) do
|
5
|
+
desc 'Whether a patch should be applied.'
|
6
|
+
|
7
|
+
newvalue(:present, :event => :opatch_installed) do
|
8
|
+
provider.present
|
9
|
+
end
|
10
|
+
|
11
|
+
newvalue(:absent, :event => :opatch_absent) do
|
12
|
+
provider.absent
|
13
|
+
end
|
14
|
+
|
15
|
+
aliasvalue(:installed, :present)
|
16
|
+
aliasvalue(:purged, :absent)
|
17
|
+
|
18
|
+
def retrieve
|
19
|
+
provider.status
|
20
|
+
end
|
21
|
+
|
22
|
+
def sync
|
23
|
+
event = super()
|
24
|
+
|
25
|
+
if property = @resource.property(:enable)
|
26
|
+
val = property.retrieve
|
27
|
+
property.sync unless property.safe_insync?(val)
|
28
|
+
end
|
29
|
+
|
30
|
+
event
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
newparam(:name) do
|
35
|
+
desc <<-EOT
|
36
|
+
The name of the OPatch.
|
37
|
+
EOT
|
38
|
+
isnamevar
|
39
|
+
end
|
40
|
+
|
41
|
+
newproperty(:test_boolean) do
|
42
|
+
#newvalue :true
|
43
|
+
newvalue :false
|
44
|
+
defaultto true
|
45
|
+
end
|
46
|
+
newparam(:patch_id) do
|
47
|
+
desc <<-EOT
|
48
|
+
The patchId of the OPatch.
|
49
|
+
EOT
|
50
|
+
end
|
51
|
+
|
52
|
+
newparam(:os_user) do
|
53
|
+
desc <<-EOT
|
54
|
+
The weblogic operating system user.
|
55
|
+
EOT
|
56
|
+
end
|
57
|
+
|
58
|
+
newparam(:oracle_product_home_dir) do
|
59
|
+
desc <<-EOT
|
60
|
+
The oracle product home folder.
|
61
|
+
EOT
|
62
|
+
end
|
63
|
+
|
64
|
+
newparam(:orainst_dir) do
|
65
|
+
desc <<-EOT
|
66
|
+
The orainst folder.
|
67
|
+
EOT
|
68
|
+
end
|
69
|
+
|
70
|
+
newparam(:extracted_patch_dir) do
|
71
|
+
desc <<-EOT
|
72
|
+
The extracted patch folder.
|
73
|
+
EOT
|
74
|
+
end
|
75
|
+
|
76
|
+
newparam(:ocmrf_file) do
|
77
|
+
desc <<-EOT
|
78
|
+
The ocmrf file.
|
79
|
+
EOT
|
80
|
+
end
|
81
|
+
|
82
|
+
newparam(:opatch_auto) do
|
83
|
+
desc <<-EOT
|
84
|
+
opatch auto bundle patch
|
85
|
+
EOT
|
86
|
+
end
|
87
|
+
|
88
|
+
newparam(:bundle_sub_patch_id) do
|
89
|
+
desc <<-EOT
|
90
|
+
One of the Sub patch number of the bundle patch
|
91
|
+
EOT
|
92
|
+
end
|
93
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
3
|
+
describe 'variable_store' do
|
5
4
|
# after :all do
|
6
5
|
# # enabling the removal slows down tests, but from time to time we may need to
|
7
6
|
# FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
|
@@ -32,5 +31,4 @@ describe "variable_store" do
|
|
32
31
|
# #clean_up_spec_dir(@path)
|
33
32
|
#
|
34
33
|
# end
|
35
|
-
|
36
34
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,18 @@ def fixture_modules_path
|
|
7
7
|
@fixture_module_path ||= File.expand_path(File.join(fixtures_path, 'modules'))
|
8
8
|
end
|
9
9
|
|
10
|
+
def fake_fixture_modules
|
11
|
+
@fake_fixture_modules ||= File.expand_path(File.join(fixtures_path, 'fixture_modules'))
|
12
|
+
end
|
13
|
+
|
14
|
+
def gem_template_path
|
15
|
+
@gem_template_path ||= File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'lib', 'retrospec', 'plugins', 'v1', 'plugin', 'templates'))
|
16
|
+
end
|
17
|
+
|
18
|
+
def sample_module_path
|
19
|
+
File.join(fixtures_path, 'fixture_modules', 'sample_module')
|
20
|
+
end
|
21
|
+
|
10
22
|
def fixtures_path
|
11
23
|
@fixtures_path ||= File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
|
12
24
|
end
|
@@ -15,22 +27,37 @@ def fixtures_facts_path
|
|
15
27
|
@fixtures_facts_path ||= File.expand_path(File.join(fixtures_path, 'facts'))
|
16
28
|
end
|
17
29
|
|
30
|
+
def fixtures_type_path
|
31
|
+
@fixtures_type_path ||= File.expand_path(File.join(fixtures_path, 'types'))
|
32
|
+
end
|
33
|
+
|
34
|
+
def fixtures_provider_path
|
35
|
+
@fixtures_provider_path ||= File.expand_path(File.join(fixtures_path, 'providers'))
|
36
|
+
end
|
37
|
+
|
38
|
+
def fixtures_functions_path
|
39
|
+
@fixtures_functions_path ||= File.expand_path(File.join(fixtures_path, 'functions'))
|
40
|
+
end
|
41
|
+
|
18
42
|
def clean_up_spec_dir(dir)
|
19
|
-
#puts "removing directory #{dir}"
|
43
|
+
# puts "removing directory #{dir}"
|
20
44
|
FileUtils.rm_rf(File.join(dir, 'spec'))
|
21
45
|
FileUtils.rm_f(File.join(dir, 'Gemfile'))
|
22
46
|
FileUtils.rm_f(File.join(dir, '.fixtures.yml'))
|
23
47
|
FileUtils.rm_f(File.join(dir, 'Rakefile'))
|
48
|
+
end
|
24
49
|
|
50
|
+
def retrospec_templates_path
|
51
|
+
# I like to develop the templates at the same time as this gem
|
52
|
+
# but I keep the templates in another repo
|
53
|
+
# as a side effect, puppet retrospec will pick up this environment variable as well
|
54
|
+
ENV['RETROSPEC_TEMPLATES_DIR'] ||= File.join(ENV['HOME'], 'github', 'retrospec-templates')
|
25
55
|
end
|
26
56
|
|
27
57
|
def install_module(module_name)
|
28
58
|
FileUtils.mkdir_p(fixture_modules_path)
|
29
59
|
puts `puppet module install -i #{fixture_modules_path} #{module_name}`
|
30
|
-
Dir.glob(File.join(fixture_modules_path, '**','spec')).each do |dir|
|
31
|
-
|
60
|
+
Dir.glob(File.join(fixture_modules_path, '**', 'spec')).each do |dir|
|
61
|
+
clean_up_spec_dir(dir)
|
32
62
|
end
|
33
63
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|