kitchen-dsc 0.9.3 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8d011597dabb910868fee620b3b2c6488265f6c
4
- data.tar.gz: 0b2eb214b05039e0cea4b250a5dedb8e11a9be44
3
+ metadata.gz: 2306c243f65cad6f2d2080a500d65fe71a875e53
4
+ data.tar.gz: b6d307e16a48a0c85d5500816d5c4c14e82077d6
5
5
  SHA512:
6
- metadata.gz: c0ac80911ab9efe991c35b094449d13fdbff8f73a5d3db7ae797e89c882abadf29851398695eb182679a980b567970541f567d0d09ae8011726b3593936d0722
7
- data.tar.gz: a27349e57585778c8a3aac8758f1049e3c41c4b0a478675a9130533eb27ad98fe1d4e956ca50fb92c3bab7a166e5f3f250ea8ede530a6bdbd5a9c4acd664134e
6
+ metadata.gz: d6d4e0db90b1476db78803a3641b2a650d52ae9baab67ef01356cc5cab114bc2af2f4f79e5ddc94a6f22b7d39b136b42b74c59a27ba79ecab062dc7fe79d2c2d
7
+ data.tar.gz: dcce1e8063ea43ecfea9ac0f50d2d82e40158dc2d12150d66b8c4c63e8d3cf9d9205a2e955d1d75377e2963050a43bc9afd393a54002c1d6b63dfcca327e93bc
@@ -1,21 +1,21 @@
1
1
  # encoding: utf-8
2
2
 
3
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
- require 'kitchen-dsc/version'
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
+ require "kitchen-dsc/version"
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = 'kitchen-dsc'
7
+ s.name = "kitchen-dsc"
8
8
  s.version = Kitchen::Dsc::VERSION
9
- s.authors = ['Steven Murawski']
10
- s.email = ['smurawski@chef.io']
11
- s.homepage = 'https://github.com/test-kitchen/kitchen-dsc'
12
- s.summary = 'PowerShell DSC provisioner for test-kitchen'
13
- candidates = Dir.glob('lib/**/*') + ['README.md', 'kitchen-dsc.gemspec']
9
+ s.authors = ["Steven Murawski"]
10
+ s.email = ["smurawski@chef.io"]
11
+ s.homepage = "https://github.com/test-kitchen/kitchen-dsc"
12
+ s.summary = "PowerShell DSC provisioner for test-kitchen"
13
+ candidates = Dir.glob("lib/**/*") + ["README.md", "kitchen-dsc.gemspec"]
14
14
  s.files = candidates.sort
15
15
  s.platform = Gem::Platform::RUBY
16
- s.require_paths = ['lib']
17
- s.rubyforge_project = '[none]'
18
- s.license = 'Apache 2'
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = "[none]"
18
+ s.license = "Apache 2"
19
19
  s.description = <<-EOF
20
20
  == DESCRIPTION:
21
21
 
@@ -26,16 +26,23 @@ DSC Provisioner for Test Kitchen
26
26
  TBD
27
27
 
28
28
  EOF
29
- s.add_dependency 'test-kitchen', '~> 1.10'
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'
29
+ s.add_dependency "test-kitchen", ">= 1.9"
30
+ s.add_dependency "dsc_lcm_configuration"
31
+
32
+ s.add_development_dependency "countloc", "~> 0.4"
33
+ s.add_development_dependency "rake"
34
+ s.add_development_dependency "rspec", "~> 3.2"
35
+ s.add_development_dependency "simplecov", "~> 0.9"
36
+ s.add_development_dependency "minitest", "~> 5.3"
37
+ s.add_development_dependency "yard", "~> 0.8"
38
+ s.add_development_dependency "pry"
39
+ s.add_development_dependency "pry-stack_explorer"
40
+ s.add_development_dependency "pry-byebug"
41
+ s.add_development_dependency "rb-readline"
35
42
 
36
43
  # style and complexity libraries are tightly version pinned as newer releases
37
44
  # may introduce new and undesireable style choices which would be immediately
38
45
  # enforced in CI
39
- s.add_development_dependency 'finstyle', '1.4.0'
40
- s.add_development_dependency 'cane', '2.6.2'
46
+ s.add_development_dependency "finstyle", "1.4.0"
47
+ s.add_development_dependency "cane", "2.6.2"
41
48
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kitchen
4
4
  module Dsc
5
- VERSION = '0.9.3'.freeze
5
+ VERSION = '0.10.0'.freeze
6
6
  end
7
7
  end
@@ -4,13 +4,14 @@
4
4
  #
5
5
  # Copyright (C) 2014 Steven Murawski
6
6
  #
7
- # Licensed under the MIT License.
7
+ # Licensed under the Apache 2 License.
8
8
  # See LICENSE for more details
9
9
 
10
- require 'fileutils'
11
- require 'pathname'
12
- require 'kitchen/provisioner/base'
13
- require 'kitchen/util'
10
+ require "fileutils"
11
+ require "pathname"
12
+ require "kitchen/provisioner/base"
13
+ require "kitchen/util"
14
+ require "dsc_lcm_configuration"
14
15
 
15
16
  module Kitchen
16
17
  module Provisioner
@@ -19,15 +20,15 @@ module Kitchen
19
20
 
20
21
  attr_accessor :tmp_dir
21
22
 
22
- default_config :modules_path, 'modules'
23
+ default_config :modules_path, "modules"
23
24
 
24
- default_config :configuration_script_folder, 'examples'
25
- default_config :configuration_script, 'dsc_configuration.ps1'
25
+ default_config :configuration_script_folder, "examples"
26
+ default_config :configuration_script, "dsc_configuration.ps1"
26
27
  default_config :configuration_name do |provisioner|
27
28
  provisioner.instance.suite.name
28
29
  end
29
30
 
30
- default_config :configuration_data_variable, 'ConfigurationData'
31
+ default_config :configuration_data_variable, "ConfigurationData"
31
32
  default_config :configuration_data
32
33
 
33
34
  default_config :nuget_force_bootstrap, true
@@ -35,97 +36,17 @@ module Kitchen
35
36
  default_config :gallery_name
36
37
  default_config :modules_from_gallery
37
38
 
38
- default_config :dsc_local_configuration_manager_version, 'wmf4'
39
- default_config :dsc_local_configuration_manager
39
+ default_config :dsc_local_configuration_manager_version, "wmf4"
40
+ default_config :dsc_local_configuration_manager, {}
40
41
 
41
- def override_lcm_setting?(name)
42
- if config[:dsc_local_configuration_manager].nil? ||
43
- config[:dsc_local_configuration_manager][name.to_sym].nil?
44
- false
45
- else
46
- true
47
- end
48
- end
49
-
50
- def resolve_lcm_setting(name, default_value)
51
- if override_lcm_setting? name
52
- config[:dsc_local_configuration_manager][name.to_sym]
53
- else
54
- default_value
55
- end
56
- end
57
-
58
- def lcm_settings
59
- {
60
- action_after_reboot: (resolve_lcm_setting 'action_after_reboot', 'StopConfiguration'),
61
- allow_module_overwrite: (resolve_lcm_setting 'allow_module_overwrite', false),
62
- certificate_id: (resolve_lcm_setting 'certificate_id', nil),
63
- configuration_mode: (resolve_lcm_setting 'configuration_mode', 'ApplyAndAutoCorrect'),
64
- debug_mode: (resolve_lcm_setting 'debug_mode', 'All'),
65
- reboot_if_needed: (resolve_lcm_setting 'reboot_if_needed', false),
66
- refresh_mode: (resolve_lcm_setting 'refresh_mode', 'PUSH')
67
- }
42
+ def finalize_config!(instance)
43
+ config[:dsc_local_configuration_manager] = lcm.lcm_config
44
+ super(instance)
68
45
  end
69
46
 
70
47
  def install_command
71
- lcm_config = lcm_settings
72
- case config[:dsc_local_configuration_manager_version]
73
- when 'wmf4_legacy', 'wmf4'
74
- lcm_configuration_script = <<-LCMSETUP
75
- configuration SetupLCM
76
- {
77
- LocalConfigurationManager
78
- {
79
- AllowModuleOverwrite = [bool]::Parse('#{lcm_config[:allow_module_overwrite]}')
80
- CertificateID = '#{lcm_config[:certificate_id].nil? ? '$null' : lcm_config[:certificate_id]}'
81
- ConfigurationMode = '#{lcm_config[:configuration_mode]}'
82
- ConfigurationModeFrequencyMins = #{lcm_config[:configuration_mode_frequency_mins].nil? ? '30' : lcm_config[:configuration_mode_frequency_mins]}
83
- RebootNodeIfNeeded = [bool]::Parse('#{lcm_config[:reboot_if_needed]}')
84
- RefreshFrequencyMins = #{lcm_config[:refresh_frequency_mins].nil? ? '15' : lcm_config[:refresh_frequency_mins]}
85
- RefreshMode = '#{lcm_config[:refresh_mode]}'
86
- }
87
- }
88
- LCMSETUP
89
- when 'wmf4_with_update'
90
- lcm_configuration_script = <<-LCMSETUP
91
- configuration SetupLCM
92
- {
93
- LocalConfigurationManager
94
- {
95
- ActionAfterReboot = '#{lcm_config[:action_after_reboot]}'
96
- AllowModuleOverwrite = [bool]::Parse('#{lcm_config[:allow_module_overwrite]}')
97
- CertificateID = '#{lcm_config[:certificate_id].nil? ? '$null' : lcm_config[:certificate_id]}'
98
- ConfigurationMode = '#{lcm_config[:configuration_mode]}'
99
- ConfigurationModeFrequencyMins = #{lcm_config[:configuration_mode_frequency_mins].nil? ? '30' : lcm_config[:configuration_mode_frequency_mins]}
100
- DebugMode = '#{lcm_config[:debug_mode]}'
101
- RebootNodeIfNeeded = [bool]::Parse('#{lcm_config[:reboot_if_needed]}')
102
- RefreshFrequencyMins = #{lcm_config[:refresh_frequency_mins].nil? ? '15' : lcm_config[:refresh_frequency_mins]}
103
- RefreshMode = '#{lcm_config[:refresh_mode]}'
104
- }
105
- }
106
- LCMSETUP
107
- when 'wmf5'
108
- lcm_configuration_script = <<-LCMSETUP
109
- [DSCLocalConfigurationManager()]
110
- configuration SetupLCM
111
- {
112
- Settings
113
- {
114
- ActionAfterReboot = '#{lcm_config[:action_after_reboot]}'
115
- AllowModuleOverwrite = [bool]::Parse('#{lcm_config[:allow_module_overwrite]}')
116
- CertificateID = '#{lcm_config[:certificate_id].nil? ? '$null' : lcm_config[:certificate_id]}'
117
- ConfigurationMode = '#{lcm_config[:configuration_mode]}'
118
- ConfigurationModeFrequencyMins = #{lcm_config[:configuration_mode_frequency_mins].nil? ? '15' : lcm_config[:configuration_mode_frequency_mins]}
119
- DebugMode = '#{lcm_config[:debug_mode]}'
120
- RebootNodeIfNeeded = [bool]::Parse('#{lcm_config[:reboot_if_needed]}')
121
- RefreshFrequencyMins = #{lcm_config[:refresh_frequency_mins].nil? ? '30' : lcm_config[:refresh_frequency_mins]}
122
- RefreshMode = '#{lcm_config[:refresh_mode]}'
123
- }
124
- }
125
- LCMSETUP
126
- end
127
48
  full_lcm_configuration_script = <<-EOH
128
- #{lcm_configuration_script}
49
+ #{lcm.lcm_configuration_script}
129
50
 
130
51
  $null = SetupLCM
131
52
  Set-DscLocalConfigurationManager -Path ./SetupLCM | out-null
@@ -133,63 +54,6 @@ module Kitchen
133
54
 
134
55
  wrap_powershell_code(full_lcm_configuration_script)
135
56
  end
136
- # rubocop:enable Metrics/LineLength
137
-
138
- def setup_config_directory_script
139
- "mkdir (split-path (join-path #{config[:root_path]} #{sandboxed_configuration_script})) -force | out-null"
140
- end
141
-
142
- def powershell_module_params(module_specification_hash)
143
- keys = module_specification_hash.keys.reject { |k| k.to_s.casecmp('force') == 0 }
144
- unless keys.any? { |k| k.to_s.downcase == 'repository' }
145
- keys.push(:repository)
146
- module_specification_hash[:repository] = psmodule_repository_name
147
- end
148
- keys.map { |key| "-#{key} #{module_specification_hash[key]}" }.join(' ')
149
- end
150
-
151
- def powershell_modules
152
- Array(config[:modules_from_gallery]).map do |powershell_module|
153
- params = if powershell_module.is_a? Hash
154
- powershell_module_params(powershell_module)
155
- else
156
- "-name '#{powershell_module}' -Repository #{psmodule_repository_name}"
157
- end
158
- "install-module #{params} -force | out-null"
159
- end
160
- end
161
-
162
- def nuget_force_bootstrap
163
- return unless config[:nuget_force_bootstrap]
164
- info('Bootstrapping the nuget package provider for PowerShell PackageManagement.')
165
- 'install-packageprovider nuget -force -forcebootstrap | out-null'
166
- end
167
-
168
- def psmodule_repository_name
169
- return 'PSGallery' if config[:gallery_name].nil? && config[:gallery_uri].nil?
170
- return 'testing' if config[:gallery_name].nil?
171
- config[:gallery_name]
172
- end
173
-
174
- def register_psmodule_repository
175
- return if config[:gallery_uri].nil?
176
- info("Registering a new PowerShellGet Repository - #{psmodule_repository_name}")
177
- "register-packagesource -providername PowerShellGet -name '#{psmodule_repository_name}' -location '#{config[:gallery_uri]}' -force -trusted"
178
- end
179
-
180
- def install_module_script
181
- return if config[:modules_from_gallery].nil?
182
- <<-EOH
183
- #{nuget_force_bootstrap}
184
- #{register_psmodule_repository}
185
- #{powershell_modules.join("\n")}
186
- EOH
187
- end
188
-
189
- def install_modules?
190
- config[:dsc_local_configuration_manager_version] == 'wmf5' &&
191
- !config[:modules_from_gallery].nil?
192
- end
193
57
 
194
58
  def init_command
195
59
  script = <<-EOH
@@ -201,18 +65,18 @@ module Kitchen
201
65
 
202
66
  def create_sandbox
203
67
  super
204
- info('Staging DSC Resource Modules for copy to the SUT')
68
+ info("Staging DSC Resource Modules for copy to the SUT")
205
69
  if powershell_module?
206
70
  prepare_resource_style_directory
207
71
  else
208
72
  prepare_repo_style_directory
209
73
  end
210
- info('Staging DSC configuration script for copy to the SUT')
74
+ info("Staging DSC configuration script for copy to the SUT")
211
75
  prepare_configuration_script
212
76
  end
213
77
 
214
78
  def prepare_command
215
- info('Moving DSC Resources onto PSModulePath')
79
+ info("Moving DSC Resources onto PSModulePath")
216
80
  info("Generating the MOF script for the configuration #{config[:configuration_name]}")
217
81
  stage_resources_and_generate_mof_script = <<-EOH
218
82
  if (Test-Path (join-path #{config[:root_path]} 'modules'))
@@ -237,20 +101,11 @@ module Kitchen
237
101
 
238
102
  #{configuration_data_assignment unless config[:configuration_data].nil?}
239
103
 
240
- $null = #{config[:configuration_name]} -outputpath c:/configurations #{'-configurationdata $' + configuration_data_variable}
104
+ $null = #{config[:configuration_name]} -outputpath c:/configurations #{"-configurationdata $" + configuration_data_variable}
241
105
  EOH
242
106
  debug("Shelling out: #{stage_resources_and_generate_mof_script}")
243
107
  wrap_powershell_code(stage_resources_and_generate_mof_script)
244
108
  end
245
- # rubocop:enable Metrics/LineLength
246
-
247
- def configuration_data_variable
248
- config[:configuration_data_variable].nil? ? 'ConfigurationData' : config[:configuration_data_variable]
249
- end
250
-
251
- def configuration_data_assignment
252
- '$' + configuration_data_variable + ' = ' + ps_hash(config[:configuration_data])
253
- end
254
109
 
255
110
  def run_command
256
111
  config[:retry_on_exit_code] = [35] if config[:retry_on_exit_code].empty?
@@ -280,8 +135,80 @@ module Kitchen
280
135
 
281
136
  private
282
137
 
138
+ def lcm
139
+ @lcm ||= begin
140
+ lcm_version = config[:dsc_local_configuration_manager_version]
141
+ lcm_config = config[:dsc_local_configuration_manager]
142
+ DscLcmConfiguration::Factory.create(lcm_version, lcm_config)
143
+ end
144
+ end
145
+
146
+ def setup_config_directory_script
147
+ "mkdir (split-path (join-path #{config[:root_path]} #{sandboxed_configuration_script})) -force | out-null"
148
+ end
149
+
150
+ def powershell_module_params(module_specification_hash)
151
+ keys = module_specification_hash.keys.reject { |k| k.to_s.casecmp('force') == 0 }
152
+ unless keys.any? { |k| k.to_s.downcase == 'repository' }
153
+ keys.push(:repository)
154
+ module_specification_hash[:repository] = psmodule_repository_name
155
+ end
156
+ keys.map { |key| "-#{key} #{module_specification_hash[key]}" }.join(' ')
157
+ end
158
+
159
+ def powershell_modules
160
+ Array(config[:modules_from_gallery]).map do |powershell_module|
161
+ params = if powershell_module.is_a? Hash
162
+ powershell_module_params(powershell_module)
163
+ else
164
+ "-name '#{powershell_module}' -Repository #{psmodule_repository_name}"
165
+ end
166
+ "install-module #{params} -force | out-null"
167
+ end
168
+ end
169
+
170
+ def nuget_force_bootstrap
171
+ return unless config[:nuget_force_bootstrap]
172
+ info("Bootstrapping the nuget package provider for PowerShell PackageManagement.")
173
+ "install-packageprovider nuget -force -forcebootstrap | out-null"
174
+ end
175
+
176
+ def psmodule_repository_name
177
+ return "PSGallery" if config[:gallery_name].nil? && config[:gallery_uri].nil?
178
+ return "testing" if config[:gallery_name].nil?
179
+ config[:gallery_name]
180
+ end
181
+
182
+ def register_psmodule_repository
183
+ return if config[:gallery_uri].nil?
184
+ info("Registering a new PowerShellGet Repository - #{psmodule_repository_name}")
185
+ "register-packagesource -providername PowerShellGet -name '#{psmodule_repository_name}' -location '#{config[:gallery_uri]}' -force -trusted"
186
+ end
187
+
188
+ def install_module_script
189
+ return if config[:modules_from_gallery].nil?
190
+ <<-EOH
191
+ #{nuget_force_bootstrap}
192
+ #{register_psmodule_repository}
193
+ #{powershell_modules.join("\n")}
194
+ EOH
195
+ end
196
+
197
+ def install_modules?
198
+ config[:dsc_local_configuration_manager_version] == "wmf5" &&
199
+ !config[:modules_from_gallery].nil?
200
+ end
201
+
202
+ def configuration_data_variable
203
+ config[:configuration_data_variable].nil? ? "ConfigurationData" : config[:configuration_data_variable]
204
+ end
205
+
206
+ def configuration_data_assignment
207
+ "$" + configuration_data_variable + " = " + ps_hash(config[:configuration_data])
208
+ end
209
+
283
210
  def wrap_powershell_code(code)
284
- wrap_shell_code( [ "$ProgressPreference = 'SilentlyContinue';", code ].join("\n") )
211
+ wrap_shell_code(["$ProgressPreference = 'SilentlyContinue';", code].join("\n"))
285
212
  end
286
213
 
287
214
  def powershell_module?
@@ -290,11 +217,11 @@ module Kitchen
290
217
  end
291
218
 
292
219
  def list_files(path)
293
- base_directory_content = Dir.glob(File.join(path, '*'))
294
- nested_directory_content = Dir.glob(File.join(path, '*/**/*'))
220
+ base_directory_content = Dir.glob(File.join(path, "*"))
221
+ nested_directory_content = Dir.glob(File.join(path, "*/**/*"))
295
222
  all_directory_content = [base_directory_content, nested_directory_content].flatten
296
223
 
297
- ignore_files = ['Gemfile', 'Gemfile.lock', 'README.md', 'LICENSE.txt']
224
+ ignore_files = ["Gemfile", "Gemfile.lock", "README.md", "LICENSE.txt"]
298
225
  all_directory_content.reject do |f|
299
226
  debug("Enumerating #{f}")
300
227
  ignore_files.include?(File.basename(f)) || File.directory?(f)
@@ -310,17 +237,17 @@ module Kitchen
310
237
 
311
238
  base = config[:kitchen_root]
312
239
  list_files(base).each do |src|
313
- dest = File.join(sandbox_base_module_path, src.sub("#{base}/", ''))
240
+ dest = File.join(sandbox_base_module_path, src.sub("#{base}/", ""))
314
241
  FileUtils.mkdir_p(File.dirname(dest))
315
242
  debug("Staging #{src} ")
316
243
  debug(" at #{dest}")
317
- FileUtils.cp(src, dest, preserve: true)
244
+ FileUtils.cp(src, dest, :preserve => true)
318
245
  end
319
246
  end
320
247
 
321
248
  def prepare_repo_style_directory
322
249
  module_path = File.join(config[:kitchen_root], config[:modules_path])
323
- sandbox_module_path = File.join(sandbox_path, 'modules')
250
+ sandbox_module_path = File.join(sandbox_path, "modules")
324
251
 
325
252
  if Dir.exist?(module_path)
326
253
  debug("Moving #{module_path} to #{sandbox_module_path}")
@@ -331,23 +258,23 @@ module Kitchen
331
258
  end
332
259
 
333
260
  def sandboxed_configuration_script
334
- File.join('configuration', config[:configuration_script])
261
+ File.join("configuration", config[:configuration_script])
335
262
  end
336
263
 
337
264
  def pad(depth = 0)
338
- ' ' * depth
265
+ " " * depth
339
266
  end
340
267
 
341
268
  def ps_hash(obj, depth = 0)
342
269
  if obj.is_a?(Hash)
343
270
  obj.map do |k, v|
344
- %(#{pad(depth + 2)}#{ps_hash(k)} = #{ps_hash(v, depth + 2)})
271
+ %{#{pad(depth + 2)}#{ps_hash(k)} = #{ps_hash(v, depth + 2)}}
345
272
  end.join(";\n").insert(0, "@{\n").insert(-1, "\n#{pad(depth)}}")
346
273
  elsif obj.is_a?(Array)
347
- array_string = obj.map { |v| ps_hash(v, depth + 4) }.join(',')
274
+ array_string = obj.map { |v| ps_hash(v, depth + 4) }.join(",")
348
275
  "#{pad(depth)}@(\n#{array_string}\n)"
349
276
  else
350
- %("#{obj}")
277
+ %{"#{obj}"}
351
278
  end
352
279
  end
353
280
 
@@ -0,0 +1,88 @@
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 Apache 2 License.
8
+ # See LICENSE for more details
9
+
10
+ require "kitchen/provisioner/dsc_lcm/lcm_v4"
11
+ require "kitchen/provisioner/dsc_lcm/lcm_v5"
12
+
13
+ module Kitchen
14
+ module Provisioner
15
+ module DscLcm
16
+ class LcmBase
17
+
18
+
19
+
20
+ def lcm_properties
21
+ {
22
+ :allow_module_overwrite => false,
23
+ :certificate_id => nil,
24
+ :configuration_mode => "ApplyAndAutoCorrect",
25
+ :configuration_mode_frequency_mins => 30,
26
+ :reboot_if_needed => false,
27
+ :refresh_mode => "PUSH",
28
+ :refresh_frequency_mins => 15
29
+ }
30
+ end
31
+
32
+ def initialize(config = {})
33
+ @certificate_id = nil
34
+ lcm_properties.each do |setting, value|
35
+ send(setting, value)
36
+ end
37
+
38
+ config.each do |setting, value|
39
+ send(setting, value)
40
+ end
41
+ end
42
+
43
+ def method_missing(name, *args)
44
+ return super unless lcm_properties.keys.include?(name)
45
+ if args.length == 1
46
+ instance_variable_set("@#{name}", args.first)
47
+ else
48
+ instance_variable_get("@#{name}")
49
+ end
50
+ end
51
+
52
+ def certificate_id(value = nil)
53
+ if value.nil?
54
+ @certificate_id.nil? ? "$null" : "'#{@certificate_id}'"
55
+ else
56
+ @certificate_id = value
57
+ end
58
+ end
59
+
60
+ def lcm_config
61
+ hash = {}
62
+ lcm_properties.keys.each do |key|
63
+ hash[key] = send(key)
64
+ end
65
+ hash
66
+ end
67
+
68
+ def lcm_configuration_script
69
+ <<-LCMSETUP
70
+ configuration SetupLCM
71
+ {
72
+ LocalConfigurationManager
73
+ {
74
+ AllowModuleOverwrite = [bool]::Parse('#{allow_module_overwrite}')
75
+ CertificateID = #{certificate_id}
76
+ ConfigurationMode = '#{configuration_mode}'
77
+ ConfigurationModeFrequencyMins = #{configuration_mode_frequency_mins}
78
+ RebootNodeIfNeeded = [bool]::Parse('#{reboot_if_needed}')
79
+ RefreshFrequencyMins = #{refresh_frequency_mins}
80
+ RefreshMode = '#{refresh_mode}'
81
+ }
82
+ }
83
+ LCMSETUP
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,53 @@
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 Apache 2 License.
8
+ # See LICENSE for more details
9
+
10
+ require "kitchen/provisioner/dsc_lcm/lcm_base"
11
+
12
+ module Kitchen
13
+ module Provisioner
14
+ module DscLcm
15
+ class LcmV4 < LcmBase
16
+
17
+ def lcm_properties
18
+ {
19
+ :action_after_reboot => "StopConfiguration",
20
+ :allow_module_overwrite => false,
21
+ :certificate_id => nil,
22
+ :configuration_mode => "ApplyAndAutoCorrect",
23
+ :configuration_mode_frequency_mins => 30,
24
+ :debug_mode => "All",
25
+ :reboot_if_needed => false,
26
+ :refresh_mode => "PUSH",
27
+ :refresh_frequency_mins => 15
28
+ }
29
+ end
30
+
31
+ def lcm_configuration_script
32
+ <<-LCMSETUP
33
+ configuration SetupLCM
34
+ {
35
+ LocalConfigurationManager
36
+ {
37
+ ActionAfterReboot = '#{action_after_reboot}'
38
+ AllowModuleOverwrite = [bool]::Parse('#{allow_module_overwrite}')
39
+ CertificateID = #{certificate_id}
40
+ ConfigurationMode = '#{configuration_mode}'
41
+ ConfigurationModeFrequencyMins = #{configuration_mode_frequency_mins}
42
+ DebugMode = '#{debug_mode}'
43
+ RebootNodeIfNeeded = [bool]::Parse('#{reboot_if_needed}')
44
+ RefreshFrequencyMins = #{refresh_frequency_mins}
45
+ RefreshMode = '#{refresh_mode}'
46
+ }
47
+ }
48
+ LCMSETUP
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,54 @@
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 Apache 2 License.
8
+ # See LICENSE for more details
9
+
10
+ require "kitchen/provisioner/dsc_lcm/lcm_base"
11
+
12
+ module Kitchen
13
+ module Provisioner
14
+ module DscLcm
15
+ class LcmV5 < LcmBase
16
+
17
+ def lcm_properties
18
+ {
19
+ :action_after_reboot => "StopConfiguration",
20
+ :allow_module_overwrite => false,
21
+ :certificate_id => nil,
22
+ :configuration_mode => "ApplyAndAutoCorrect",
23
+ :configuration_mode_frequency_mins => 15,
24
+ :debug_mode => "All",
25
+ :reboot_if_needed => false,
26
+ :refresh_mode => "PUSH",
27
+ :refresh_frequency_mins => 30
28
+ }
29
+ end
30
+
31
+ def lcm_configuration_script
32
+ <<-LCMSETUP
33
+ [DSCLocalConfigurationManager()]
34
+ configuration SetupLCM
35
+ {
36
+ Settings
37
+ {
38
+ ActionAfterReboot = '#{action_after_reboot}'
39
+ AllowModuleOverwrite = [bool]::Parse('#{allow_module_overwrite}')
40
+ CertificateID = #{certificate_id}
41
+ ConfigurationMode = '#{configuration_mode}'
42
+ ConfigurationModeFrequencyMins = #{configuration_mode_frequency_mins}
43
+ DebugMode = '#{debug_mode}'
44
+ RebootNodeIfNeeded = [bool]::Parse('#{reboot_if_needed}')
45
+ RefreshFrequencyMins = #{refresh_frequency_mins}
46
+ RefreshMode = '#{refresh_mode}'
47
+ }
48
+ }
49
+ LCMSETUP
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-dsc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.10.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: 2016-06-23 00:00:00.000000000 Z
11
+ date: 2016-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '1.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dsc_lcm_configuration
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: countloc
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,90 @@ dependencies:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0.9'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.3'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.8'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.8'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry-stack_explorer
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry-byebug
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rb-readline
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
83
181
  - !ruby/object:Gem::Dependency
84
182
  name: finstyle
85
183
  requirement: !ruby/object:Gem::Requirement
@@ -127,6 +225,9 @@ files:
127
225
  - kitchen-dsc.gemspec
128
226
  - lib/kitchen-dsc/version.rb
129
227
  - lib/kitchen/provisioner/dsc.rb
228
+ - lib/kitchen/provisioner/dsc_lcm/lcm_base.rb
229
+ - lib/kitchen/provisioner/dsc_lcm/lcm_v4.rb
230
+ - lib/kitchen/provisioner/dsc_lcm/lcm_v5.rb
130
231
  homepage: https://github.com/test-kitchen/kitchen-dsc
131
232
  licenses:
132
233
  - Apache 2