kitchen-dsc 0.2.3 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d254d3dbbf50778bf30979b2eb6081b954c60910
4
- data.tar.gz: 042dff4ac31ee1bc0c807485766715b54cbb5115
3
+ metadata.gz: 42a5ff439d0535a553f3adb5a8c514e8f1bf7b91
4
+ data.tar.gz: 00d6cedc27bce66bb5e9e2533b5e6ccc08949516
5
5
  SHA512:
6
- metadata.gz: 5f914b5dbfe83dd6a90f8ec40c52ed9560324ca108a9b48f1775436defcdc349e26ced8911ee344a9ce192302e3fdda583134286bc3ca6cba1b0aaa45a66684b
7
- data.tar.gz: 4bcc0777b07a3d50fc0e7ff87a4b4f12c99678e80f1340a20895b796fbd978460c1e1d92081ff209388f37292f4245ef1a8d718d13f0ae928ee9b81b1e1e9e3f
6
+ metadata.gz: 84b3e6a84d2c80ce8755115f3c3a5c31a941660f4273145bbbc3f29546110fe7fb769c02f7985756d1d359cbc1fa67c1e1faacad6601955d9fb30f5e8be575c4
7
+ data.tar.gz: 0b71ff875f127f6734ad85137a02f91072708b084ca6b145c4d544090105b7b3be085ee32389217bd6088dc6a7706a2043760d260019ac4c7d3871ce122b5850
data/README.md CHANGED
@@ -1,45 +1,45 @@
1
- # kitchen-dsc
2
- A Test Kitchen Provisioner for PowerShell DSC
3
-
4
-
5
- ## Requirements
6
- You'll need a driver box with WMF4 or greater (ONLY WINDOWS SYSTEMS)
7
-
8
- ## Installation & Setup
9
- You'll need the test-kitchen & kitchen-dsc gems installed in your system, along with kitchen-vagrant or some ther suitable driver for test-kitchen.
10
-
11
- ## Example Configurations
12
- [Repository Style Testing](https://github.com/smurawski/dsc-kitchen-project)
13
- [Module Style Testing](https://github.com/powershellorg/cwebadministration/tree/smurawski/adding_tests)
14
-
15
- ## Configuration Settings
16
- * configuration_script_folder
17
- * Defaults to 'examples'.
18
- * The location of a PowerShell script(s) containing the DSC configuration command(s).
19
- * configuration_script
20
- * Defaults to 'dsc_configuration.ps1'
21
- * The name of the PowerShell script containing the DSC configuration command(s).
22
- * The configuration command name used defaults to the suite name (and can be overridden by the run_list parameter in the suite).
23
- * dsc_local_configuration_manager_version
24
- * Defaults to 'wmf4' ()
25
- * Identifies what version of the LCM is in place
26
- * Other valid values are 'wmf4_with_update' and 'wmf5'
27
- * Currently the only difference between wmf4 and wmf4_with_update/wmf5 is the action_after_reboot and the debug_mode settings. Eventually, I'd like to add support for partial configurations, pull servers, etc..
28
- * In this context, wmf4_with_update refers to wmf4 with KB3000850 applied (to add support for WMF 5 generated configurations, plus some fixes).
29
- * dsc_local_configuration_manager
30
- * Settings for the LCM
31
- * Defaults are:
32
- * action_after_reboot = 'StopConfiguration' # wmf4_with_update or wmf5
33
- * allow_module_overwrite = false
34
- * certificate_id = nil
35
- * configuration_mode = 'ApplyAndAutoCorrect'
36
- * configuration_mode_frequency_mins = 30
37
- * debug_mode = 'All' # wmf4_with_update or wmf5
38
- * refresh_frequency_mins = 15
39
- * refresh_mode = 'PUSH'
40
-
41
- ### Specific to repository style testing
42
- * modules_path
43
- * Defaults to 'modules'.
44
- * Points to the location of modules containing DSC resources to upload
45
- * This path is relative to the root of the repository (the location of the .kitchen.yml).
1
+ # kitchen-dsc
2
+ A Test Kitchen Provisioner for PowerShell DSC
3
+
4
+
5
+ ## Requirements
6
+ You'll need a driver box with WMF4 or greater (ONLY WINDOWS SYSTEMS)
7
+
8
+ ## Installation & Setup
9
+ You'll need the test-kitchen & kitchen-dsc gems installed in your system, along with kitchen-vagrant or some ther suitable driver for test-kitchen.
10
+
11
+ ## Example Configurations
12
+ [Repository Style Testing](https://github.com/smurawski/dsc-kitchen-project)
13
+ [Module Style Testing](https://github.com/powershellorg/cwebadministration/tree/smurawski/adding_tests)
14
+
15
+ ## Configuration Settings
16
+ * configuration_script_folder
17
+ * Defaults to 'examples'.
18
+ * The location of a PowerShell script(s) containing the DSC configuration command(s).
19
+ * configuration_script
20
+ * Defaults to 'dsc_configuration.ps1'
21
+ * The name of the PowerShell script containing the DSC configuration command(s).
22
+ * The configuration command name used defaults to the suite name (and can be overridden by the run_list parameter in the suite).
23
+ * dsc_local_configuration_manager_version
24
+ * Defaults to 'wmf4' ()
25
+ * Identifies what version of the LCM is in place
26
+ * Other valid values are 'wmf4_with_update' and 'wmf5'
27
+ * Currently the only difference between wmf4 and wmf4_with_update/wmf5 is the action_after_reboot and the debug_mode settings. Eventually, I'd like to add support for partial configurations, pull servers, etc..
28
+ * In this context, wmf4_with_update refers to wmf4 with KB3000850 applied (to add support for WMF 5 generated configurations, plus some fixes).
29
+ * dsc_local_configuration_manager
30
+ * Settings for the LCM
31
+ * Defaults are:
32
+ * action_after_reboot = 'StopConfiguration' # wmf4_with_update or wmf5
33
+ * allow_module_overwrite = false
34
+ * certificate_id = nil
35
+ * configuration_mode = 'ApplyAndAutoCorrect'
36
+ * configuration_mode_frequency_mins = 30
37
+ * debug_mode = 'All' # wmf4_with_update or wmf5
38
+ * refresh_frequency_mins = 15
39
+ * refresh_mode = 'PUSH'
40
+
41
+ ### Specific to repository style testing
42
+ * modules_path
43
+ * Defaults to 'modules'.
44
+ * Points to the location of modules containing DSC resources to upload
45
+ * This path is relative to the root of the repository (the location of the .kitchen.yml).
data/kitchen-dsc.gemspec CHANGED
@@ -1,30 +1,30 @@
1
- # encoding: utf-8
2
-
3
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
- require 'kitchen-dsc/version'
5
-
6
- Gem::Specification.new do |s|
7
- s.name = 'kitchen-dsc'
8
- s.version = Kitchen::Dsc::VERSION
9
- s.authors = ['Steven Murawski']
10
- s.email = ['steven.murawski@gmail.com']
11
- s.homepage = 'https://github.com/smurawski/kitchen-dsc'
12
- s.summary = 'PowerShell DSC provisioner for test-kitchen'
13
- candidates = Dir.glob('lib/**/*') + ['README.md', 'kitchen-dsc.gemspec']
14
- s.files = candidates.sort
15
- s.platform = Gem::Platform::RUBY
16
- s.require_paths = ['lib']
17
- s.rubyforge_project = '[none]'
18
- s.license = 'MIT'
19
- s.description = <<-EOF
20
- == DESCRIPTION:
21
-
22
- DSC Provisioner for Test Kitchen
23
-
24
- == FEATURES:
25
-
26
- TBD
27
-
28
- EOF
29
-
30
- end
1
+ # encoding: utf-8
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
+ require 'kitchen-dsc/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'kitchen-dsc'
8
+ s.version = Kitchen::Dsc::VERSION
9
+ s.authors = ['Steven Murawski']
10
+ s.email = ['steven.murawski@gmail.com']
11
+ s.homepage = 'https://github.com/smurawski/kitchen-dsc'
12
+ s.summary = 'PowerShell DSC provisioner for test-kitchen'
13
+ candidates = Dir.glob('lib/**/*') + ['README.md', 'kitchen-dsc.gemspec']
14
+ s.files = candidates.sort
15
+ s.platform = Gem::Platform::RUBY
16
+ s.require_paths = ['lib']
17
+ s.rubyforge_project = '[none]'
18
+ s.license = 'MIT'
19
+ s.description = <<-EOF
20
+ == DESCRIPTION:
21
+
22
+ DSC Provisioner for Test Kitchen
23
+
24
+ == FEATURES:
25
+
26
+ TBD
27
+
28
+ EOF
29
+
30
+ end
@@ -1,205 +1,209 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Steven Murawski (<steven.murawski@gmail.com>)
4
- #
5
- # Copyright (C) 2014 Steven Murawski
6
- #
7
- # Licensed under the MIT License.
8
- # See LICENSE for more details
9
-
10
- require 'fileutils'
11
- require 'pathname'
12
- require 'kitchen/provisioner/base'
13
- require 'kitchen/util'
14
-
15
- module Kitchen
16
-
17
- module Provisioner
18
- class Dsc < Base
19
- kitchen_provisioner_api_version 2
20
-
21
- attr_accessor :tmp_dir
22
-
23
- default_config :modules_path, 'modules'
24
- default_config :configuration_script_folder, 'examples'
25
- default_config :configuration_script, 'dsc_configuration.ps1'
26
-
27
- default_config :dsc_local_configuration_manager_version, 'wmf4'
28
- default_config :dsc_local_configuration_manager, {
29
- action_after_reboot: 'StopConfiguration',
30
- allow_module_overwrite: false,
31
- certificate_id: nil,
32
- configuration_mode: 'ApplyAndAutoCorrect',
33
- configuration_mode_frequency_mins: 30,
34
- debug_mode: 'All',
35
- reboot_if_needed: false,
36
- refresh_frequency_mins: 15,
37
- refresh_mode: 'PUSH'
38
- }
39
-
40
- # Disable line length check, it is all embedded script.
41
- # rubocop:disable Metrics/LineLength
42
- def install_command
43
- lcm_config = config[:dsc_local_configuration_manager]
44
- case config[:dsc_local_configuration_manager_version]
45
- when 'wmf4_legacy', 'wmf4'
46
- lcm_configuration_script = <<-LCMSETUP
47
- configuration SetupLCM
48
- {
49
- LocalConfigurationManager
50
- {
51
- AllowModuleOverwrite = [bool]::Parse('#{lcm_config[:allow_module_overwrite]}')
52
- CertificateID = '#{lcm_config[:certificate_id].nil? ? '$null' : lcm_config[:certificate_id]}'
53
- ConfigurationMode = '#{lcm_config[:configuration_mode]}'
54
- ConfigurationModeFrequencyMins = #{lcm_config[:configuration_mode_frequency_mins]}
55
- RebootNodeIfNeeded = [bool]::Parse('#{lcm_config[:reboot_if_needed]}')
56
- RefreshFrequencyMins = #{lcm_config[:refresh_frequency_mins]}
57
- RefreshMode = '#{lcm_config[:refresh_mode]}'
58
- }
59
- }
60
- SetupLCM
61
- Set-DscLocalConfigurationManager -Path ./SetupLCM
62
- LCMSETUP
63
- when 'wmf4_with_update', 'wmf5'
64
- lcm_configuration_script = <<-LCMSETUP
65
- configuration SetupLCM
66
- {
67
- LocalConfigurationManager
68
- {
69
- ActionAfterReboot = '#{lcm_config[:action_after_reboot]}'
70
- AllowModuleOverwrite = [bool]::Parse('#{lcm_config[:allow_module_overwrite]}')
71
- CertificateID = '#{lcm_config[:certificate_id].nil? ? '$null' : lcm_config[:certificate_id]}'
72
- ConfigurationMode = '#{lcm_config[:configuration_mode]}'
73
- ConfigurationModeFrequencyMins = #{lcm_config[:configuration_mode_frequency_mins]}
74
- DebugMode = '#{lcm_config[:debug_mode]}'
75
- RebootNodeIfNeeded = [bool]::Parse('#{lcm_config[:reboot_if_needed]}')
76
- RefreshFrequencyMins = #{lcm_config[:refresh_frequency_mins]}
77
- RefreshMode = '#{lcm_config[:refresh_mode]}'
78
- }
79
- }
80
- SetupLCM
81
- Set-DscLocalConfigurationManager -Path ./SetupLCM
82
- LCMSETUP
83
- end
84
- wrap_shell_code(lcm_configuration_script)
85
- end
86
- # rubocop:enable Metrics/LineLength
87
-
88
- def init_command
89
- end
90
-
91
- def create_sandbox
92
- super
93
- info('Staging DSC Resource Modules for copy to the SUT')
94
- if resource_module?
95
- prepare_resource_style_directory
96
- else
97
- prepare_repo_style_directory
98
- end
99
- info('Staging DSC configuration script for copy to the SUT')
100
- prepare_configuration_script
101
- end
102
-
103
- # Disable line length check, it is all logging and embedded script.
104
- # rubocop:disable Metrics/LineLength
105
- def prepare_command
106
- info('Moving DSC Resources onto PSModulePath')
107
- info("Generating the MOF script for the configuration #{current_configuration}")
108
- stage_resources_and_generate_mof_script = <<-EOH
109
- dir ( join-path #{config[:root_path]} 'modules/*') -directory |
110
- copy-item -destination $env:programfiles/windowspowershell/modules/ -recurse -force
111
-
112
- if (-not (test-path 'c:/configurations'))
113
- {
114
- mkdir 'c:/configurations' | out-null
115
- }
116
- $ConfigurationScriptPath = Join-path #{config[:root_path]} #{sandboxed_configuration_script}
117
- if (-not (test-path $ConfigurationScriptPath))
118
- {
119
- throw "Failed to find $ConfigurationScriptPath"
120
- }
121
- invoke-expression (get-content $ConfigurationScriptPath -raw)
122
- #{current_configuration} -outputpath c:/configurations | out-null
123
- EOH
124
- debug("Shelling out: #{stage_resources_and_generate_mof_script}")
125
- wrap_shell_code(stage_resources_and_generate_mof_script)
126
- end
127
- # rubocop:enable Metrics/LineLength
128
-
129
- def run_command
130
- info("Running the configuration #{current_configuration}")
131
- run_configuration_script = <<-EOH
132
- $job = start-dscconfiguration -Path c:/configurations/ -force
133
- $job | wait-job
134
- $job.childjobs[0].verbose
135
- EOH
136
-
137
- debug("Shelling out: #{run_configuration_script}")
138
- wrap_shell_code(run_configuration_script)
139
- end
140
-
141
- private
142
-
143
- def current_configuration
144
- config.keys.include?(:run_list) ? config[:run_list][0] : @instance.suite.name
145
- end
146
-
147
- def resource_module?
148
- module_metadata_file = File.join(config[:kitchen_root], "#{module_name}.psd1")
149
- module_dsc_resource_folder = File.join(config[:kitchen_root], 'DSCResources')
150
- File.exist?(module_metadata_file) &&
151
- File.exist?(module_dsc_resource_folder)
152
- end
153
-
154
- def list_files(path)
155
- base_directory_content = Dir.glob(File.join(path, '*'))
156
- nested_directory_content = Dir.glob(File.join(path, '*/**/*'))
157
- all_directory_content =([base_directory_content, nested_directory_content]).flatten
158
-
159
- ignore_files = ['Gemfile', 'Gemfile.lock', 'README.md', 'LICENSE.txt']
160
- all_directory_content.reject do |f|
161
- debug("Enumerating #{f}")
162
- ignore_files.include?(File.basename(f)) || File.directory?(f)
163
- end
164
- end
165
-
166
- def module_name
167
- File.basename(config[:kitchen_root])
168
- end
169
-
170
- def prepare_resource_style_directory
171
- sandbox_base_module_path = File.join(sandbox_path, "modules/#{module_name}")
172
-
173
- base = config[:kitchen_root]
174
- list_files(base).each do |src|
175
- dest = File.join(sandbox_base_module_path, src.sub("#{base}/", ''))
176
- FileUtils.mkdir_p(File.dirname(dest))
177
- debug("Staging #{src} ")
178
- debug(" at #{dest}")
179
- FileUtils.cp(src, dest, preserve: true)
180
- end
181
- end
182
-
183
- def prepare_repo_style_directory
184
- module_path = File.join(config[:kitchen_root], config[:modules_path])
185
- sandbox_module_path = File.join(sandbox_path, 'modules')
186
-
187
- debug("Moving #{module_path} to #{sandbox_module_path}")
188
- FileUtils.cp_r(module_path, sandbox_module_path)
189
- end
190
-
191
- def sandboxed_configuration_script
192
- File.join('./configuration', config[:configuration_script])
193
- end
194
-
195
- def prepare_configuration_script
196
- configuration_script_file = File.join(config[:configuration_script_folder], config[:configuration_script])
197
- configuration_script_path = File.join(config[:kitchen_root], configuration_script_file)
198
- sandbox_configuration_script_path = File.join(sandbox_path, sandboxed_configuration_script)
199
- FileUtils.mkdir_p(File.dirname(sandbox_configuration_script_path))
200
- debug("Moving #{configuration_script_path} to #{sandbox_configuration_script_path}")
201
- FileUtils.cp(configuration_script_path, sandbox_configuration_script_path)
202
- end
203
- end
204
- end
205
- end
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Steven Murawski (<steven.murawski@gmail.com>)
4
+ #
5
+ # Copyright (C) 2014 Steven Murawski
6
+ #
7
+ # Licensed under the MIT License.
8
+ # See LICENSE for more details
9
+
10
+ require 'fileutils'
11
+ require 'pathname'
12
+ require 'kitchen/provisioner/base'
13
+ require 'kitchen/util'
14
+
15
+ module Kitchen
16
+
17
+ module Provisioner
18
+ class Dsc < Base
19
+ kitchen_provisioner_api_version 2
20
+
21
+ attr_accessor :tmp_dir
22
+
23
+ default_config :modules_path, 'modules'
24
+ default_config :configuration_script_folder, 'examples'
25
+ default_config :configuration_script, 'dsc_configuration.ps1'
26
+ default_config :configuration_name do |provisioner|
27
+ provisioner.instance.suite.name
28
+ end
29
+ default_config :configuration_data_variable
30
+
31
+ default_config :dsc_local_configuration_manager_version, 'wmf4'
32
+ default_config :dsc_local_configuration_manager, {
33
+ action_after_reboot: 'StopConfiguration',
34
+ allow_module_overwrite: false,
35
+ certificate_id: nil,
36
+ configuration_mode: 'ApplyAndAutoCorrect',
37
+ configuration_mode_frequency_mins: 30,
38
+ debug_mode: 'All',
39
+ reboot_if_needed: false,
40
+ refresh_frequency_mins: 15,
41
+ refresh_mode: 'PUSH'
42
+ }
43
+
44
+ # Disable line length check, it is all embedded script.
45
+ # rubocop:disable Metrics/LineLength
46
+ def install_command
47
+ lcm_config = config[:dsc_local_configuration_manager]
48
+ case config[:dsc_local_configuration_manager_version]
49
+ when 'wmf4_legacy', 'wmf4'
50
+ lcm_configuration_script = <<-LCMSETUP
51
+ configuration SetupLCM
52
+ {
53
+ LocalConfigurationManager
54
+ {
55
+ AllowModuleOverwrite = [bool]::Parse('#{lcm_config[:allow_module_overwrite]}')
56
+ CertificateID = '#{lcm_config[:certificate_id].nil? ? '$null' : lcm_config[:certificate_id]}'
57
+ ConfigurationMode = '#{lcm_config[:configuration_mode]}'
58
+ ConfigurationModeFrequencyMins = #{lcm_config[:configuration_mode_frequency_mins]}
59
+ RebootNodeIfNeeded = [bool]::Parse('#{lcm_config[:reboot_if_needed]}')
60
+ RefreshFrequencyMins = #{lcm_config[:refresh_frequency_mins]}
61
+ RefreshMode = '#{lcm_config[:refresh_mode]}'
62
+ }
63
+ }
64
+ SetupLCM
65
+ Set-DscLocalConfigurationManager -Path ./SetupLCM
66
+ LCMSETUP
67
+ when 'wmf4_with_update', 'wmf5'
68
+ lcm_configuration_script = <<-LCMSETUP
69
+ configuration SetupLCM
70
+ {
71
+ LocalConfigurationManager
72
+ {
73
+ ActionAfterReboot = '#{lcm_config[:action_after_reboot]}'
74
+ AllowModuleOverwrite = [bool]::Parse('#{lcm_config[:allow_module_overwrite]}')
75
+ CertificateID = '#{lcm_config[:certificate_id].nil? ? '$null' : lcm_config[:certificate_id]}'
76
+ ConfigurationMode = '#{lcm_config[:configuration_mode]}'
77
+ ConfigurationModeFrequencyMins = #{lcm_config[:configuration_mode_frequency_mins]}
78
+ DebugMode = '#{lcm_config[:debug_mode]}'
79
+ RebootNodeIfNeeded = [bool]::Parse('#{lcm_config[:reboot_if_needed]}')
80
+ RefreshFrequencyMins = #{lcm_config[:refresh_frequency_mins]}
81
+ RefreshMode = '#{lcm_config[:refresh_mode]}'
82
+ }
83
+ }
84
+ $null = SetupLCM
85
+ Set-DscLocalConfigurationManager -Path ./SetupLCM
86
+ LCMSETUP
87
+ end
88
+ wrap_shell_code(lcm_configuration_script)
89
+ end
90
+ # rubocop:enable Metrics/LineLength
91
+
92
+ def init_command
93
+ end
94
+
95
+ def create_sandbox
96
+ super
97
+ info('Staging DSC Resource Modules for copy to the SUT')
98
+ if resource_module?
99
+ prepare_resource_style_directory
100
+ else
101
+ prepare_repo_style_directory
102
+ end
103
+ info('Staging DSC configuration script for copy to the SUT')
104
+ prepare_configuration_script
105
+ end
106
+
107
+ # Disable line length check, it is all logging and embedded script.
108
+ # rubocop:disable Metrics/LineLength
109
+ def prepare_command
110
+ info('Moving DSC Resources onto PSModulePath')
111
+ info("Generating the MOF script for the configuration #{config[:configuration_name]}")
112
+ stage_resources_and_generate_mof_script = <<-EOH
113
+ dir ( join-path #{config[:root_path]} 'modules/*') -directory |
114
+ copy-item -destination $env:programfiles/windowspowershell/modules/ -recurse -force
115
+
116
+ if (-not (test-path 'c:/configurations'))
117
+ {
118
+ mkdir 'c:/configurations' | out-null
119
+ }
120
+ $ConfigurationScriptPath = Join-path #{config[:root_path]} #{sandboxed_configuration_script}
121
+ if (-not (test-path $ConfigurationScriptPath))
122
+ {
123
+ throw "Failed to find $ConfigurationScriptPath"
124
+ }
125
+ invoke-expression (get-content $ConfigurationScriptPath -raw)
126
+ if (-not (get-command #{config[:configuration_name]}))
127
+ {
128
+ throw "Failed to create a configuration command #{config[:configuration_name]}"
129
+ }
130
+ $null = #{config[:configuration_name]} -outputpath c:/configurations #{'-configurationdata $' + config[:configuration_data_variable] if config[:configuration_data_variable]}
131
+ EOH
132
+ debug("Shelling out: #{stage_resources_and_generate_mof_script}")
133
+ wrap_shell_code(stage_resources_and_generate_mof_script)
134
+ end
135
+ # rubocop:enable Metrics/LineLength
136
+
137
+ def run_command
138
+ info("Running the configuration #{config[:configuration_name]}")
139
+ run_configuration_script = <<-EOH
140
+ $job = start-dscconfiguration -Path c:/configurations/ -force
141
+ $job | wait-job
142
+ $job.childjobs[0].verbose
143
+ EOH
144
+
145
+ debug("Shelling out: #{run_configuration_script}")
146
+ wrap_shell_code(run_configuration_script)
147
+ end
148
+
149
+ private
150
+
151
+ def resource_module?
152
+ module_metadata_file = File.join(config[:kitchen_root], "#{module_name}.psd1")
153
+ module_dsc_resource_folder = File.join(config[:kitchen_root], 'DSCResources')
154
+ File.exist?(module_metadata_file) &&
155
+ File.exist?(module_dsc_resource_folder)
156
+ end
157
+
158
+ def list_files(path)
159
+ base_directory_content = Dir.glob(File.join(path, '*'))
160
+ nested_directory_content = Dir.glob(File.join(path, '*/**/*'))
161
+ all_directory_content =([base_directory_content, nested_directory_content]).flatten
162
+
163
+ ignore_files = ['Gemfile', 'Gemfile.lock', 'README.md', 'LICENSE.txt']
164
+ all_directory_content.reject do |f|
165
+ debug("Enumerating #{f}")
166
+ ignore_files.include?(File.basename(f)) || File.directory?(f)
167
+ end
168
+ end
169
+
170
+ def module_name
171
+ File.basename(config[:kitchen_root])
172
+ end
173
+
174
+ def prepare_resource_style_directory
175
+ sandbox_base_module_path = File.join(sandbox_path, "modules/#{module_name}")
176
+
177
+ base = config[:kitchen_root]
178
+ list_files(base).each do |src|
179
+ dest = File.join(sandbox_base_module_path, src.sub("#{base}/", ''))
180
+ FileUtils.mkdir_p(File.dirname(dest))
181
+ debug("Staging #{src} ")
182
+ debug(" at #{dest}")
183
+ FileUtils.cp(src, dest, preserve: true)
184
+ end
185
+ end
186
+
187
+ def prepare_repo_style_directory
188
+ module_path = File.join(config[:kitchen_root], config[:modules_path])
189
+ sandbox_module_path = File.join(sandbox_path, 'modules')
190
+
191
+ debug("Moving #{module_path} to #{sandbox_module_path}")
192
+ FileUtils.cp_r(module_path, sandbox_module_path)
193
+ end
194
+
195
+ def sandboxed_configuration_script
196
+ File.join('configuration', config[:configuration_script])
197
+ end
198
+
199
+ def prepare_configuration_script
200
+ configuration_script_file = File.join(config[:configuration_script_folder], config[:configuration_script])
201
+ configuration_script_path = File.join(config[:kitchen_root], configuration_script_file)
202
+ sandbox_configuration_script_path = File.join(sandbox_path, sandboxed_configuration_script)
203
+ FileUtils.mkdir_p(File.dirname(sandbox_configuration_script_path))
204
+ debug("Moving #{configuration_script_path} to #{sandbox_configuration_script_path}")
205
+ FileUtils.cp(configuration_script_path, sandbox_configuration_script_path)
206
+ end
207
+ end
208
+ end
209
+ end
@@ -1,7 +1,7 @@
1
- # encoding: utf-8
2
-
3
- module Kitchen
4
- module Dsc
5
- VERSION = '0.2.3'
6
- end
7
- end
1
+ # encoding: utf-8
2
+
3
+ module Kitchen
4
+ module Dsc
5
+ VERSION = '0.3.0'
6
+ end
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-dsc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Murawski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |+
14
14
  == DESCRIPTION:
@@ -39,16 +39,16 @@ require_paths:
39
39
  - lib
40
40
  required_ruby_version: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - '>='
42
+ - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  requirements: []
51
- rubyforge_project: '[none]'
51
+ rubyforge_project: "[none]"
52
52
  rubygems_version: 2.4.4
53
53
  signing_key:
54
54
  specification_version: 4