kitchen-dsc 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,108 +1,118 @@
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
- ### Note:
14
- You will see a delay in the return of the run details due to an difference in how the verbose stream is returned for DSC runs between WMF versions, so I return the verbose stream after the job completes. I'd love to live stream the results, but that'll take a bit more experimentation. (PR's welcome!)
15
-
16
- ## Example Configurations
17
- * [Repository Style Testing](https://github.com/smurawski/dsc-kitchen-project)
18
- * [Module Style Testing](https://github.com/powershellorg/cwebadministration/tree/smurawski/adding_tests)
19
-
20
- ## Configuration Settings
21
- * configuration_script_folder
22
- * Defaults to 'examples'.
23
- * The location of a PowerShell script(s) containing the DSC configuration command(s).
24
-
25
- * configuration_script
26
- * Defaults to 'dsc_configuration.ps1'
27
- * The name of the PowerShell script containing the DSC configuration command(s) (and possibly configuration data)
28
-
29
- * configuration_name
30
- * Name of the configuration to run, defaults to the suite name.
31
-
32
- * configuration_data
33
- * A YAML representation of what should be passed to the configuration.
34
- * Overrides any configurationdata variable assigned in the configuration script.
35
-
36
- * configuration_data_variable
37
- * Defaults to 'ConfigurationData'
38
- * Name of the variable that contains the ConfigurationData hashtable
39
- * Can be defined in the configuration script or via the `configuration_data` configuration setting.
40
-
41
- * dsc_local_configuration_manager_version
42
- * Defaults to 'wmf4'
43
- * Identifies what version of the LCM is in place
44
- * Other valid values are 'wmf4_with_update' and 'wmf5'
45
- * 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..
46
- * In this context, wmf4_with_update refers to wmf4 with KB3000850 applied (to add support for WMF 5 generated configurations, plus some fixes).
47
-
48
- * dsc_local_configuration_manager
49
- * Settings for the LCM
50
- * Defaults are:
51
- * action_after_reboot = 'StopConfiguration' # wmf4_with_update or wmf5
52
- * reboot_if_needed = false
53
- * allow_module_overwrite = false
54
- * certificate_id = nil
55
- * configuration_mode = 'ApplyAndAutoCorrect'
56
- * configuration_mode_frequency_mins = 30 # 15 on wmf5
57
- * debug_mode = 'All' # wmf4_with_update
58
- * refresh_frequency_mins = 15 # 30 on wmf5
59
- * refresh_mode = 'PUSH'
60
-
61
- * modules_from_gallery
62
- * Requires WMF 5
63
- * Takes a string (for one module) or an array (for multiple) to install from the gallery
64
- * Or takes a hash with keys matching the parameters for install-module.
65
- * Name is required.
66
- * Force is automatically used and not required as part of the hash table.
67
- * Repository defaults to either PSGallery or any custom feed defined, but can be overriden here.
68
-
69
- * gallery_name
70
- * Custom PowerShell gallery name to install modules from.
71
- * If there is no package source with this name registered on the machine, then gallery_uri must be configured as well.
72
-
73
- * gallery_uri
74
- * URI for a custom PowerShell gallery feed.
75
-
76
- ### Specific to repository style testing
77
- * modules_path
78
- * Defaults to 'modules'.
79
- * Points to the location of modules containing DSC resources to upload
80
- * This path is relative to the root of the repository (the location of the .kitchen.yml).
81
-
82
- ## Example
83
-
84
- ```yaml
85
- provisioner:
86
- - name: dsc
87
- dsc_local_configuration_manager_version: wmf5
88
- dsc_local_configuration_manager:
89
- reboot_if_needed: true
90
- debug_mode: none
91
- configuration_script_folder: .
92
- configuration_script: SampleConfig.ps1
93
- gallery_uri: https://ci.appveyor.com/nuget/xWebAdministration
94
- gallery_name: xWebDevFeed
95
- modules_from_gallery:
96
- - xWebAdministration
97
- - name: xComputerManagement
98
- requiredversion: 1.4.0.0
99
- repository: PSGallery
100
-
101
- suite:
102
- - name: test
103
- provisioner:
104
- configuration_data:
105
- AllNodes:
106
- - nodename: localhost
107
- role: webserver
108
- ```
1
+ # kitchen-dsc
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/kitchen-dsc.svg)](http://badge.fury.io/rb/kitchen-dsc)
4
+
5
+ A Test Kitchen Provisioner for PowerShell DSC
6
+
7
+ ## Status
8
+
9
+ This software project is no longer under active development as it has no active maintainers. The software may continue to work for some or all use cases, but issues filed in GitHub will most likely not be triaged. If a new maintainer is interested in working on this project please come chat with us in #test-kitchen on Chef Community Slack.
10
+
11
+ ## Requirements
12
+
13
+ You'll need a driver box with WMF4 or greater (ONLY WINDOWS SYSTEMS)
14
+
15
+ ## Installation & Setup
16
+
17
+ 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.
18
+
19
+ ### Note:
20
+
21
+ You will see a delay in the return of the run details due to an difference in how the verbose stream is returned for DSC runs between WMF versions, so I return the verbose stream after the job completes. I'd love to live stream the results, but that'll take a bit more experimentation. (PR's welcome!)
22
+
23
+ ## Example Configurations
24
+
25
+ * [Repository Style Testing](https://github.com/smurawski/dsc-kitchen-project)
26
+ * [Module Style Testing](https://github.com/powershellorg/cwebadministration/tree/smurawski/adding_tests)
27
+
28
+ ## Configuration Settings
29
+
30
+ * configuration_script_folder
31
+ * Defaults to 'examples'.
32
+ * The location of a PowerShell script(s) containing the DSC configuration command(s).
33
+
34
+ * configuration_script
35
+ * Defaults to 'dsc_configuration.ps1'
36
+ * The name of the PowerShell script containing the DSC configuration command(s) (and possibly configuration data)
37
+
38
+ * configuration_name
39
+ * Name of the configuration to run, defaults to the suite name.
40
+
41
+ * configuration_data
42
+ * A YAML representation of what should be passed to the configuration.
43
+ * Overrides any configurationdata variable assigned in the configuration script.
44
+
45
+ * configuration_data_variable
46
+ * Defaults to 'ConfigurationData'
47
+ * Name of the variable that contains the ConfigurationData hashtable
48
+ * Can be defined in the configuration script or via the `configuration_data` configuration setting.
49
+
50
+ * dsc_local_configuration_manager_version
51
+ * Defaults to 'wmf4'
52
+ * Identifies what version of the LCM is in place
53
+ * Other valid values are 'wmf4_with_update' and 'wmf5'
54
+ * 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..
55
+ * In this context, wmf4_with_update refers to wmf4 with KB3000850 applied (to add support for WMF 5 generated configurations, plus some fixes).
56
+
57
+ * dsc_local_configuration_manager
58
+ * Settings for the LCM
59
+ * Defaults are:
60
+ * action_after_reboot = 'StopConfiguration' # wmf4_with_update or wmf5
61
+ * reboot_if_needed = false
62
+ * allow_module_overwrite = false
63
+ * certificate_id = nil
64
+ * configuration_mode = 'ApplyAndAutoCorrect'
65
+ * configuration_mode_frequency_mins = 30 # 15 on wmf5
66
+ * debug_mode = 'All' # wmf4_with_update
67
+ * refresh_frequency_mins = 15 # 30 on wmf5
68
+ * refresh_mode = 'PUSH'
69
+
70
+ * modules_from_gallery
71
+ * Requires WMF 5
72
+ * Takes a string (for one module) or an array (for multiple) to install from the gallery
73
+ * Or takes a hash with keys matching the parameters for install-module.
74
+ * Name is required.
75
+ * Force is automatically used and not required as part of the hash table.
76
+ * Repository defaults to either PSGallery or any custom feed defined, but can be overriden here.
77
+
78
+ * gallery_name
79
+ * Custom PowerShell gallery name to install modules from.
80
+ * If there is no package source with this name registered on the machine, then gallery_uri must be configured as well.
81
+
82
+ * gallery_uri
83
+ * URI for a custom PowerShell gallery feed.
84
+
85
+ ### Specific to repository style testing
86
+
87
+ * modules_path
88
+ * Defaults to 'modules'.
89
+ * Points to the location of modules containing DSC resources to upload
90
+ * This path is relative to the root of the repository (the location of the .kitchen.yml).
91
+
92
+ ## Example
93
+
94
+ ```yaml
95
+ provisioner:
96
+ - name: dsc
97
+ dsc_local_configuration_manager_version: wmf5
98
+ dsc_local_configuration_manager:
99
+ reboot_if_needed: true
100
+ debug_mode: none
101
+ configuration_script_folder: .
102
+ configuration_script: SampleConfig.ps1
103
+ gallery_uri: https://ci.appveyor.com/nuget/xWebAdministration
104
+ gallery_name: xWebDevFeed
105
+ modules_from_gallery:
106
+ - xWebAdministration
107
+ - name: xComputerManagement
108
+ requiredversion: 1.4.0.0
109
+ repository: PSGallery
110
+
111
+ suite:
112
+ - name: test
113
+ provisioner:
114
+ configuration_data:
115
+ AllNodes:
116
+ - nodename: localhost
117
+ role: webserver
118
+ ```
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require "bundler/gem_tasks"
2
+ require "chefstyle"
3
+ require "rubocop/rake_task"
4
+
5
+ RuboCop::RakeTask.new(:style) do |task|
6
+ task.options += ["--display-cop-names", "--no-color"]
7
+ end
8
+
9
+ # Create the spec task.
10
+ require "rspec/core/rake_task"
11
+ RSpec::Core::RakeTask.new(:test, :tag) do |t, args|
12
+ t.rspec_opts = [].tap do |a|
13
+ a << "--color"
14
+ a << "--format #{ENV["CI"] ? "documentation" : "progress"}"
15
+ a << "--backtrace" if ENV["VERBOSE"] || ENV["DEBUG"]
16
+ a << "--seed #{ENV["SEED"]}" if ENV["SEED"]
17
+ a << "--tag #{args[:tag]}" if args[:tag]
18
+ a << "--default-path test"
19
+ a << "-I test/spec"
20
+ end.join(" ")
21
+ end
data/kitchen-dsc.gemspec CHANGED
@@ -1,48 +1,21 @@
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 = ["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
- 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.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"
42
-
43
- # style and complexity libraries are tightly version pinned as newer releases
44
- # may introduce new and undesireable style choices which would be immediately
45
- # enforced in CI
46
- s.add_development_dependency "finstyle", "1.4.0"
47
- s.add_development_dependency "cane", "2.6.2"
48
- end
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "kitchen-dsc/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "kitchen-dsc"
7
+ gem.version = Kitchen::Dsc::VERSION
8
+ gem.authors = ["Test Kitchen Team"]
9
+ gem.email = ["help@sous-chefs.org"]
10
+ gem.homepage = "https://github.com/test-kitchen/kitchen-dsc"
11
+ gem.summary = "PowerShell DSC provisioner for test-kitchen"
12
+ gem.description = "PowerShell DSC provisioner for test-kitchen"
13
+ gem.files = `git ls-files`.split($/)
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.platform = Gem::Platform::RUBY
16
+ gem.require_paths = ["lib"]
17
+ gem.license = "Apache-2.0"
18
+
19
+ gem.add_dependency "dsc_lcm_configuration"
20
+ gem.add_dependency "test-kitchen", ">= 1.9"
21
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Steven Murawski (<steven.murawski@gmail.com>)
4
3
  #
@@ -7,8 +6,8 @@
7
6
  # Licensed under the Apache 2 License.
8
7
  # See LICENSE for more details
9
8
 
10
- require "fileutils"
11
- require "pathname"
9
+ require "fileutils" unless defined?(FileUtils)
10
+ require "pathname" unless defined?(Pathname)
12
11
  require "kitchen/provisioner/base"
13
12
  require "kitchen/util"
14
13
  require "dsc_lcm_configuration"
@@ -55,9 +54,9 @@ module Kitchen
55
54
  end
56
55
 
57
56
  def init_command
58
- script = <<-EOH
59
- #{setup_config_directory_script}
60
- #{install_module_script if install_modules?}
57
+ script = <<~EOH
58
+ #{setup_config_directory_script}
59
+ #{install_module_script if install_modules?}
61
60
  EOH
62
61
  wrap_powershell_code(script)
63
62
  end
@@ -77,7 +76,7 @@ module Kitchen
77
76
  def prepare_command
78
77
  info("Moving DSC Resources onto PSModulePath")
79
78
  scripts = <<-EOH
80
-
79
+
81
80
  if (Test-Path (join-path #{config[:root_path]} 'modules'))
82
81
  {
83
82
  dir ( join-path #{config[:root_path]} 'modules/*') -directory |
@@ -95,38 +94,38 @@ module Kitchen
95
94
  ensure_array(config[:configuration_name]).each do |configuration|
96
95
  info("Generating the MOF script for the configuration #{configuration}")
97
96
  stage_resources_and_generate_mof_script = <<-EOH
98
-
97
+
99
98
  if(Test-Path c:/configurations/#{configuration})
100
99
  {
101
100
  Remove-Item -Recurse -Force c:/configurations/#{configuration}
102
101
  }
103
-
102
+
104
103
  $Error.clear()
105
-
104
+
106
105
  if (-not (test-path 'c:/configurations'))
107
106
  {
108
107
  mkdir 'c:/configurations' | out-null
109
108
  }
110
-
109
+
111
110
  if (-not (get-command #{configuration}))
112
111
  {
113
112
  throw "Failed to create a configuration command #{configuration}"
114
113
  }
115
-
114
+
116
115
  #{configuration_data_assignment unless config[:configuration_data].nil?}
117
-
116
+
118
117
  try{
119
118
  $null = #{configuration} -outputpath c:/configurations/#{configuration} #{"-configurationdata $" + configuration_data_variable}
120
119
  }
121
120
  catch{
122
121
  }
123
-
122
+
124
123
  if($Error -ne $null)
125
124
  {
126
125
  $Error[-1]
127
126
  exit 1
128
127
  }
129
-
128
+
130
129
  EOH
131
130
  scripts << stage_resources_and_generate_mof_script
132
131
  end
@@ -137,7 +136,7 @@ module Kitchen
137
136
  def run_command
138
137
  config[:retry_on_exit_code] = [35] if config[:retry_on_exit_code].empty?
139
138
  config[:max_retries] = 3 if config[:max_retries] == 1
140
- scripts = ''
139
+ scripts = ""
141
140
  ensure_array(config[:configuration_name]).each do |configuration|
142
141
  info("Running the configuration #{configuration}")
143
142
  run_configuration_script = <<-EOH
@@ -177,12 +176,12 @@ module Kitchen
177
176
  end
178
177
 
179
178
  def powershell_module_params(module_specification_hash)
180
- keys = module_specification_hash.keys.reject { |k| k.to_s.casecmp('force') == 0 }
181
- unless keys.any? { |k| k.to_s.downcase == 'repository' }
179
+ keys = module_specification_hash.keys.reject { |k| k.to_s.casecmp("force") == 0 }
180
+ unless keys.any? { |k| k.to_s.downcase == "repository" }
182
181
  keys.push(:repository)
183
182
  module_specification_hash[:repository] = psmodule_repository_name
184
183
  end
185
- keys.map { |key| "-#{key} #{module_specification_hash[key]}" }.join(' ')
184
+ keys.map { |key| "-#{key} #{module_specification_hash[key]}" }.join(" ")
186
185
  end
187
186
 
188
187
  def powershell_modules
@@ -198,6 +197,7 @@ module Kitchen
198
197
 
199
198
  def nuget_force_bootstrap
200
199
  return unless config[:nuget_force_bootstrap]
200
+
201
201
  info("Bootstrapping the nuget package provider for PowerShell PackageManagement.")
202
202
  "install-packageprovider nuget -force -forcebootstrap | out-null"
203
203
  end
@@ -205,17 +205,20 @@ module Kitchen
205
205
  def psmodule_repository_name
206
206
  return "PSGallery" if config[:gallery_name].nil? && config[:gallery_uri].nil?
207
207
  return "testing" if config[:gallery_name].nil?
208
+
208
209
  config[:gallery_name]
209
210
  end
210
211
 
211
212
  def register_psmodule_repository
212
213
  return if config[:gallery_uri].nil?
214
+
213
215
  info("Registering a new PowerShellGet Repository - #{psmodule_repository_name}")
214
216
  "register-packagesource -providername PowerShellGet -name '#{psmodule_repository_name}' -location '#{config[:gallery_uri]}' -force -trusted"
215
217
  end
216
218
 
217
219
  def install_module_script
218
220
  return if config[:modules_from_gallery].nil?
221
+
219
222
  <<-EOH
220
223
  #{nuget_force_bootstrap}
221
224
  #{register_psmodule_repository}
@@ -270,7 +273,7 @@ module Kitchen
270
273
  FileUtils.mkdir_p(File.dirname(dest))
271
274
  debug("Staging #{src} ")
272
275
  debug(" at #{dest}")
273
- FileUtils.cp(src, dest, :preserve => true)
276
+ FileUtils.cp(src, dest, preserve: true)
274
277
  end
275
278
  end
276
279
 
@@ -318,9 +321,9 @@ module Kitchen
318
321
 
319
322
  def ensure_array(thing)
320
323
  if thing.is_a?(Array)
321
- return thing
324
+ thing
322
325
  else
323
- return [thing]
326
+ [thing]
324
327
  end
325
328
  end
326
329
  end
@@ -1,88 +1,86 @@
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
1
+ #
2
+ # Author:: Steven Murawski (<steven.murawski@gmail.com>)
3
+ #
4
+ # Copyright (C) 2014 Steven Murawski
5
+ #
6
+ # Licensed under the Apache 2 License.
7
+ # See LICENSE for more details
8
+
9
+ require_relative "lcm_v4"
10
+ require_relative "lcm_v5"
11
+
12
+ module Kitchen
13
+ module Provisioner
14
+ module DscLcm
15
+ class LcmBase
16
+
17
+ def lcm_properties
18
+ {
19
+ allow_module_overwrite: false,
20
+ certificate_id: nil,
21
+ configuration_mode: "ApplyAndAutoCorrect",
22
+ configuration_mode_frequency_mins: 30,
23
+ reboot_if_needed: false,
24
+ refresh_mode: "PUSH",
25
+ refresh_frequency_mins: 15,
26
+ }
27
+ end
28
+
29
+ def initialize(config = {})
30
+ @certificate_id = nil
31
+ lcm_properties.each do |setting, value|
32
+ send(setting, value)
33
+ end
34
+
35
+ config.each do |setting, value|
36
+ send(setting, value)
37
+ end
38
+ end
39
+
40
+ def method_missing(name, *args)
41
+ return super unless lcm_properties.keys.include?(name)
42
+
43
+ if args.length == 1
44
+ instance_variable_set("@#{name}", args.first)
45
+ else
46
+ instance_variable_get("@#{name}")
47
+ end
48
+ end
49
+
50
+ def certificate_id(value = nil)
51
+ if value.nil?
52
+ @certificate_id.nil? ? "$null" : "'#{@certificate_id}'"
53
+ else
54
+ @certificate_id = value
55
+ end
56
+ end
57
+
58
+ def lcm_config
59
+ hash = {}
60
+ lcm_properties.keys.each do |key|
61
+ hash[key] = send(key)
62
+ end
63
+ hash
64
+ end
65
+
66
+ def lcm_configuration_script
67
+ <<-LCMSETUP
68
+ configuration SetupLCM
69
+ {
70
+ LocalConfigurationManager
71
+ {
72
+ AllowModuleOverwrite = [bool]::Parse('#{allow_module_overwrite}')
73
+ CertificateID = #{certificate_id}
74
+ ConfigurationMode = '#{configuration_mode}'
75
+ ConfigurationModeFrequencyMins = #{configuration_mode_frequency_mins}
76
+ RebootNodeIfNeeded = [bool]::Parse('#{reboot_if_needed}')
77
+ RefreshFrequencyMins = #{refresh_frequency_mins}
78
+ RefreshMode = '#{refresh_mode}'
79
+ }
80
+ }
81
+ LCMSETUP
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end