kitchen-dsc 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +50 -45
- data/kitchen-dsc.gemspec +41 -30
- data/lib/kitchen/provisioner/dsc.rb +241 -209
- data/lib/kitchen-dsc/version.rb +7 -7
- metadata +103 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2427c0b295f805d273274902356713f2b43f7830
|
4
|
+
data.tar.gz: 71aa87ccaa88df2c2d8421d634553494afde038e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3e29b049b24fc18d267ef0e90f3eb3e2ff6c8de25b9dc1a793bbec011373df3ca872ade1734a320b1550c20954ea9acb2a9c3d3bb550b12c5b42d153a91114b
|
7
|
+
data.tar.gz: a272c13d4c2b14b07123f1ddc0e4e8350593cdab32169dfb4ebdd0539b35808729bbfd1c933c6cbc871ef74a8f35d992bcd015e89219ce0b76dc07859ffb9353
|
data/README.md
CHANGED
@@ -1,45 +1,50 @@
|
|
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
|
-
* action_after_reboot
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
*
|
38
|
-
*
|
39
|
-
*
|
40
|
-
|
41
|
-
|
42
|
-
*
|
43
|
-
|
44
|
-
|
45
|
-
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/kitchen-dsc.svg)](http://badge.fury.io/rb/kitchen-dsc)
|
2
|
+
|
3
|
+
# kitchen-dsc
|
4
|
+
A Test Kitchen Provisioner for PowerShell DSC
|
5
|
+
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
You'll need a driver box with WMF4 or greater (ONLY WINDOWS SYSTEMS)
|
9
|
+
|
10
|
+
## Installation & Setup
|
11
|
+
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.
|
12
|
+
|
13
|
+
## Example Configurations
|
14
|
+
* [Repository Style Testing](https://github.com/smurawski/dsc-kitchen-project)
|
15
|
+
* [Module Style Testing](https://github.com/powershellorg/cwebadministration/tree/smurawski/adding_tests)
|
16
|
+
|
17
|
+
## Configuration Settings
|
18
|
+
* configuration_script_folder
|
19
|
+
* Defaults to 'examples'.
|
20
|
+
* The location of a PowerShell script(s) containing the DSC configuration command(s).
|
21
|
+
* configuration_script
|
22
|
+
* Defaults to 'dsc_configuration.ps1'
|
23
|
+
* The name of the PowerShell script containing the DSC configuration command(s) (and possibly configuration data)
|
24
|
+
* configuration_name
|
25
|
+
* Name of the configuration to run, defaults to the suite name.
|
26
|
+
* configuration_data_variable
|
27
|
+
* Name of the variable in the configuration_script that contains the ConfigurationData hashtable
|
28
|
+
* dsc_local_configuration_manager_version
|
29
|
+
* Defaults to 'wmf4' ()
|
30
|
+
* Identifies what version of the LCM is in place
|
31
|
+
* Other valid values are 'wmf4_with_update' and 'wmf5'
|
32
|
+
* 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..
|
33
|
+
* In this context, wmf4_with_update refers to wmf4 with KB3000850 applied (to add support for WMF 5 generated configurations, plus some fixes).
|
34
|
+
* dsc_local_configuration_manager
|
35
|
+
* Settings for the LCM
|
36
|
+
* Defaults are:
|
37
|
+
* action_after_reboot = 'StopConfiguration' # wmf4_with_update or wmf5
|
38
|
+
* allow_module_overwrite = false
|
39
|
+
* certificate_id = nil
|
40
|
+
* configuration_mode = 'ApplyAndAutoCorrect'
|
41
|
+
* configuration_mode_frequency_mins = 30 # 15 on wmf5
|
42
|
+
* debug_mode = 'All' # wmf4_with_update
|
43
|
+
* refresh_frequency_mins = 15 # 30 on wmf5
|
44
|
+
* refresh_mode = 'PUSH'
|
45
|
+
|
46
|
+
### Specific to repository style testing
|
47
|
+
* modules_path
|
48
|
+
* Defaults to 'modules'.
|
49
|
+
* Points to the location of modules containing DSC resources to upload
|
50
|
+
* This path is relative to the root of the repository (the location of the .kitchen.yml).
|
data/kitchen-dsc.gemspec
CHANGED
@@ -1,30 +1,41 @@
|
|
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/**/*') +
|
14
|
-
s.files = candidates.sort
|
15
|
-
s.platform = Gem::Platform::RUBY
|
16
|
-
s.require_paths = ['lib']
|
17
|
-
s.rubyforge_project = '[none]'
|
18
|
-
s.license = '
|
19
|
-
s.description = <<-EOF
|
20
|
-
== DESCRIPTION:
|
21
|
-
|
22
|
-
DSC Provisioner for Test Kitchen
|
23
|
-
|
24
|
-
== FEATURES:
|
25
|
-
|
26
|
-
TBD
|
27
|
-
|
28
|
-
EOF
|
29
|
-
|
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 = 'Apache 2'
|
19
|
+
s.description = <<-EOF
|
20
|
+
== DESCRIPTION:
|
21
|
+
|
22
|
+
DSC Provisioner for Test Kitchen
|
23
|
+
|
24
|
+
== FEATURES:
|
25
|
+
|
26
|
+
TBD
|
27
|
+
|
28
|
+
EOF
|
29
|
+
s.add_dependency "test-kitchen", "~> 1.4"
|
30
|
+
|
31
|
+
s.add_development_dependency "countloc", "~> 0.4"
|
32
|
+
s.add_development_dependency "rake"
|
33
|
+
s.add_development_dependency "rspec", "~> 3.2"
|
34
|
+
s.add_development_dependency "simplecov", "~> 0.9"
|
35
|
+
|
36
|
+
# style and complexity libraries are tightly version pinned as newer releases
|
37
|
+
# may introduce new and undesireable style choices which would be immediately
|
38
|
+
# enforced in CI
|
39
|
+
s.add_development_dependency "finstyle", "1.4.0"
|
40
|
+
s.add_development_dependency "cane", "2.6.2"
|
41
|
+
end
|
@@ -1,209 +1,241 @@
|
|
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
|
-
|
25
|
-
default_config :
|
26
|
-
default_config :
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
default_config :
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
debug_mode: 'All',
|
39
|
-
reboot_if_needed: false,
|
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
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
EOH
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
$
|
142
|
-
$
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
def
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
end
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
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
|
+
|
25
|
+
default_config :configuration_script_folder, 'examples'
|
26
|
+
default_config :configuration_script, 'dsc_configuration.ps1'
|
27
|
+
default_config :configuration_name do |provisioner|
|
28
|
+
provisioner.instance.suite.name
|
29
|
+
end
|
30
|
+
default_config :configuration_data_variable
|
31
|
+
|
32
|
+
default_config :dsc_local_configuration_manager_version, 'wmf4'
|
33
|
+
default_config :dsc_local_configuration_manager, {
|
34
|
+
action_after_reboot: 'StopConfiguration',
|
35
|
+
allow_module_overwrite: false,
|
36
|
+
certificate_id: nil,
|
37
|
+
configuration_mode: 'ApplyAndAutoCorrect',
|
38
|
+
debug_mode: 'All',
|
39
|
+
reboot_if_needed: false,
|
40
|
+
refresh_mode: 'PUSH'
|
41
|
+
}
|
42
|
+
|
43
|
+
# Disable line length check, it is all embedded script.
|
44
|
+
# rubocop:disable Metrics/LineLength
|
45
|
+
def install_command
|
46
|
+
lcm_config = config[:dsc_local_configuration_manager]
|
47
|
+
case config[:dsc_local_configuration_manager_version]
|
48
|
+
when 'wmf4_legacy', 'wmf4'
|
49
|
+
lcm_configuration_script = <<-LCMSETUP
|
50
|
+
configuration SetupLCM
|
51
|
+
{
|
52
|
+
LocalConfigurationManager
|
53
|
+
{
|
54
|
+
AllowModuleOverwrite = [bool]::Parse('#{lcm_config[:allow_module_overwrite]}')
|
55
|
+
CertificateID = '#{lcm_config[:certificate_id].nil? ? '$null' : lcm_config[:certificate_id]}'
|
56
|
+
ConfigurationMode = '#{lcm_config[:configuration_mode]}'
|
57
|
+
ConfigurationModeFrequencyMins = #{lcm_config[:configuration_mode_frequency_mins].nil? ? '30' : lcm_config[:configuration_mode_frequency_mins]}
|
58
|
+
RebootNodeIfNeeded = [bool]::Parse('#{lcm_config[:reboot_if_needed]}')
|
59
|
+
RefreshFrequencyMins = #{lcm_config[:refresh_frequency_mins].nil? ? '15' : lcm[:refresh_frequency_mins]}
|
60
|
+
RefreshMode = '#{lcm_config[:refresh_mode]}'
|
61
|
+
}
|
62
|
+
}
|
63
|
+
LCMSETUP
|
64
|
+
when 'wmf4_with_update'
|
65
|
+
lcm_configuration_script = <<-LCMSETUP
|
66
|
+
configuration SetupLCM
|
67
|
+
{
|
68
|
+
LocalConfigurationManager
|
69
|
+
{
|
70
|
+
ActionAfterReboot = '#{lcm_config[:action_after_reboot]}'
|
71
|
+
AllowModuleOverwrite = [bool]::Parse('#{lcm_config[:allow_module_overwrite]}')
|
72
|
+
CertificateID = '#{lcm_config[:certificate_id].nil? ? '$null' : lcm_config[:certificate_id]}'
|
73
|
+
ConfigurationMode = '#{lcm_config[:configuration_mode]}'
|
74
|
+
ConfigurationModeFrequencyMins = #{lcm_config[:configuration_mode_frequency_mins].nil? ? '30' : lcm_config[:configuration_mode_frequency_mins]}
|
75
|
+
DebugMode = '#{lcm_config[:debug_mode]}'
|
76
|
+
RebootNodeIfNeeded = [bool]::Parse('#{lcm_config[:reboot_if_needed]}')
|
77
|
+
RefreshFrequencyMins = #{lcm_config[:refresh_frequency_mins].nil? ? '15' : lcm[:refresh_frequency_mins]}
|
78
|
+
RefreshMode = '#{lcm_config[:refresh_mode]}'
|
79
|
+
}
|
80
|
+
}
|
81
|
+
LCMSETUP
|
82
|
+
when 'wmf5'
|
83
|
+
lcm_configuration_script = <<-LCMSETUP
|
84
|
+
configuration SetupLCM
|
85
|
+
{
|
86
|
+
LocalConfigurationManager
|
87
|
+
{
|
88
|
+
ActionAfterReboot = '#{lcm_config[:action_after_reboot]}'
|
89
|
+
AllowModuleOverwrite = [bool]::Parse('#{lcm_config[:allow_module_overwrite]}')
|
90
|
+
CertificateID = '#{lcm_config[:certificate_id].nil? ? '$null' : lcm_config[:certificate_id]}'
|
91
|
+
ConfigurationMode = '#{lcm_config[:configuration_mode]}'
|
92
|
+
ConfigurationModeFrequencyMins = #{lcm_config[:configuration_mode_frequency_mins].nil? ? '15' : lcm_config[:configuration_mode_frequency_mins]}
|
93
|
+
RebootNodeIfNeeded = [bool]::Parse('#{lcm_config[:reboot_if_needed]}')
|
94
|
+
RefreshFrequencyMins = #{lcm_config[:refresh_frequency_mins].nil? ? '30' : lcm[:refresh_frequency_mins]}
|
95
|
+
RefreshMode = '#{lcm_config[:refresh_mode]}'
|
96
|
+
}
|
97
|
+
}
|
98
|
+
LCMSETUP
|
99
|
+
end
|
100
|
+
full_lcm_configuration_script = <<-EOH
|
101
|
+
#{lcm_configuration_script}
|
102
|
+
|
103
|
+
$null = SetupLCM
|
104
|
+
Set-DscLocalConfigurationManager -Path ./SetupLCM
|
105
|
+
EOH
|
106
|
+
|
107
|
+
wrap_shell_code(full_lcm_configuration_script)
|
108
|
+
end
|
109
|
+
# rubocop:enable Metrics/LineLength
|
110
|
+
|
111
|
+
def init_command
|
112
|
+
end
|
113
|
+
|
114
|
+
def create_sandbox
|
115
|
+
super
|
116
|
+
info('Staging DSC Resource Modules for copy to the SUT')
|
117
|
+
if resource_module? || class_resource_module?
|
118
|
+
prepare_resource_style_directory
|
119
|
+
else
|
120
|
+
prepare_repo_style_directory
|
121
|
+
end
|
122
|
+
info('Staging DSC configuration script for copy to the SUT')
|
123
|
+
prepare_configuration_script
|
124
|
+
end
|
125
|
+
|
126
|
+
# Disable line length check, it is all logging and embedded script.
|
127
|
+
# rubocop:disable Metrics/LineLength
|
128
|
+
def prepare_command
|
129
|
+
info('Moving DSC Resources onto PSModulePath')
|
130
|
+
info("Generating the MOF script for the configuration #{config[:configuration_name]}")
|
131
|
+
stage_resources_and_generate_mof_script = <<-EOH
|
132
|
+
if (Test-Path (join-path #{config[:root_path]} 'modules'))
|
133
|
+
{
|
134
|
+
dir ( join-path #{config[:root_path]} 'modules/*') -directory |
|
135
|
+
copy-item -destination $env:programfiles/windowspowershell/modules/ -recurse -force
|
136
|
+
}
|
137
|
+
if (-not (test-path 'c:/configurations'))
|
138
|
+
{
|
139
|
+
mkdir 'c:/configurations' | out-null
|
140
|
+
}
|
141
|
+
$ConfigurationScriptPath = Join-path #{config[:root_path]} #{sandboxed_configuration_script}
|
142
|
+
if (-not (test-path $ConfigurationScriptPath))
|
143
|
+
{
|
144
|
+
throw "Failed to find $ConfigurationScriptPath"
|
145
|
+
}
|
146
|
+
invoke-expression (get-content $ConfigurationScriptPath -raw)
|
147
|
+
if (-not (get-command #{config[:configuration_name]}))
|
148
|
+
{
|
149
|
+
throw "Failed to create a configuration command #{config[:configuration_name]}"
|
150
|
+
}
|
151
|
+
$null = #{config[:configuration_name]} -outputpath c:/configurations #{'-configurationdata $' + config[:configuration_data_variable] if config[:configuration_data_variable]}
|
152
|
+
EOH
|
153
|
+
debug("Shelling out: #{stage_resources_and_generate_mof_script}")
|
154
|
+
wrap_shell_code(stage_resources_and_generate_mof_script)
|
155
|
+
end
|
156
|
+
# rubocop:enable Metrics/LineLength
|
157
|
+
|
158
|
+
def run_command
|
159
|
+
info("Running the configuration #{config[:configuration_name]}")
|
160
|
+
run_configuration_script = <<-EOH
|
161
|
+
$job = start-dscconfiguration -Path c:/configurations/ -force
|
162
|
+
$job | wait-job
|
163
|
+
$job.childjobs[0].verbose
|
164
|
+
EOH
|
165
|
+
|
166
|
+
debug("Shelling out: #{run_configuration_script}")
|
167
|
+
wrap_shell_code(run_configuration_script)
|
168
|
+
end
|
169
|
+
|
170
|
+
private
|
171
|
+
|
172
|
+
def resource_module?
|
173
|
+
module_metadata_file = File.join(config[:kitchen_root], "#{module_name}.psd1")
|
174
|
+
module_dsc_resource_folder = File.join(config[:kitchen_root], 'DSCResources')
|
175
|
+
File.exist?(module_metadata_file) &&
|
176
|
+
File.exist?(module_dsc_resource_folder)
|
177
|
+
end
|
178
|
+
|
179
|
+
def class_resource_module?
|
180
|
+
module_metadata_file = File.join(config[:kitchen_root], "#{module_name}.psd1")
|
181
|
+
module_dsc_resource_folder = File.join(config[:kitchen_root], 'DSCResources')
|
182
|
+
File.exist?(module_metadata_file) &&
|
183
|
+
!File.exist?(module_dsc_resource_folder)
|
184
|
+
end
|
185
|
+
|
186
|
+
def list_files(path)
|
187
|
+
base_directory_content = Dir.glob(File.join(path, '*'))
|
188
|
+
nested_directory_content = Dir.glob(File.join(path, '*/**/*'))
|
189
|
+
all_directory_content =([base_directory_content, nested_directory_content]).flatten
|
190
|
+
|
191
|
+
ignore_files = ['Gemfile', 'Gemfile.lock', 'README.md', 'LICENSE.txt']
|
192
|
+
all_directory_content.reject do |f|
|
193
|
+
debug("Enumerating #{f}")
|
194
|
+
ignore_files.include?(File.basename(f)) || File.directory?(f)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def module_name
|
199
|
+
File.basename(config[:kitchen_root])
|
200
|
+
end
|
201
|
+
|
202
|
+
def prepare_resource_style_directory
|
203
|
+
sandbox_base_module_path = File.join(sandbox_path, "modules/#{module_name}")
|
204
|
+
|
205
|
+
base = config[:kitchen_root]
|
206
|
+
list_files(base).each do |src|
|
207
|
+
dest = File.join(sandbox_base_module_path, src.sub("#{base}/", ''))
|
208
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
209
|
+
debug("Staging #{src} ")
|
210
|
+
debug(" at #{dest}")
|
211
|
+
FileUtils.cp(src, dest, preserve: true)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def prepare_repo_style_directory
|
216
|
+
module_path = File.join(config[:kitchen_root], config[:modules_path])
|
217
|
+
sandbox_module_path = File.join(sandbox_path, 'modules')
|
218
|
+
|
219
|
+
if Dir.exist?(module_path)
|
220
|
+
debug("Moving #{module_path} to #{sandbox_module_path}")
|
221
|
+
FileUtils.cp_r(module_path, sandbox_module_path)
|
222
|
+
else
|
223
|
+
debug("The modules path #{module_path} was not found. Not moving to #{sandbox_module_path}.")
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def sandboxed_configuration_script
|
228
|
+
File.join('configuration', config[:configuration_script])
|
229
|
+
end
|
230
|
+
|
231
|
+
def prepare_configuration_script
|
232
|
+
configuration_script_file = File.join(config[:configuration_script_folder], config[:configuration_script])
|
233
|
+
configuration_script_path = File.join(config[:kitchen_root], configuration_script_file)
|
234
|
+
sandbox_configuration_script_path = File.join(sandbox_path, sandboxed_configuration_script)
|
235
|
+
FileUtils.mkdir_p(File.dirname(sandbox_configuration_script_path))
|
236
|
+
debug("Moving #{configuration_script_path} to #{sandbox_configuration_script_path}")
|
237
|
+
FileUtils.cp(configuration_script_path, sandbox_configuration_script_path)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
data/lib/kitchen-dsc/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Kitchen
|
4
|
-
module Dsc
|
5
|
-
VERSION = '0.
|
6
|
-
end
|
7
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Dsc
|
5
|
+
VERSION = '0.4.0'
|
6
|
+
end
|
7
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-dsc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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-
|
12
|
-
dependencies:
|
11
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: test-kitchen
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: countloc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.9'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: finstyle
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.4.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.4.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: cane
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.6.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.6.2
|
13
111
|
description: |+
|
14
112
|
== DESCRIPTION:
|
15
113
|
|
@@ -31,7 +129,7 @@ files:
|
|
31
129
|
- lib/kitchen/provisioner/dsc.rb
|
32
130
|
homepage: https://github.com/smurawski/kitchen-dsc
|
33
131
|
licenses:
|
34
|
-
-
|
132
|
+
- Apache 2
|
35
133
|
metadata: {}
|
36
134
|
post_install_message:
|
37
135
|
rdoc_options: []
|
@@ -49,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
147
|
version: '0'
|
50
148
|
requirements: []
|
51
149
|
rubyforge_project: "[none]"
|
52
|
-
rubygems_version: 2.4.
|
150
|
+
rubygems_version: 2.4.8
|
53
151
|
signing_key:
|
54
152
|
specification_version: 4
|
55
153
|
summary: PowerShell DSC provisioner for test-kitchen
|