vagrant-dsc 0.0.1 → 1.0.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: 1dd5efd1b9d993187d7cf8d74f014de2744618dd
4
- data.tar.gz: 1e9aefbc93396c81c5aedb56d44aa19db81033de
3
+ metadata.gz: c8ec166dab0cf1c326f7d0f943abcee534574d68
4
+ data.tar.gz: aad0961c447ebf11921c64c920d43463fb2410b5
5
5
  SHA512:
6
- metadata.gz: 3522383b0a55be34bf4dc30b5ea3ce64d1a4db84a3eca3e3e83ad6bce93f8188a03b19e7bca8886c27c7a84f561dd774071cf302574f2b78508c0d202a8d22da
7
- data.tar.gz: 033aa03d21640d320f5604e323d22d3d22025e203b10db6deaca764a0248324c9f875761014b5261a3991cc528a878a041ba6af8df8aba0b08de28261eb078d5
6
+ metadata.gz: 16b406fbc437d601f40536c687efac1536588655a4813a3592ebfc9f19f0496cfaa1750a87b640d8ba5e429e68e453fd07d45774c1817408e1650b0ad3eac0bb
7
+ data.tar.gz: 603e019f5b4444ef240733f8a8eb417f3ed003a3ed394fe64212218736936c5549b8401409d47ea7f901a962d119694411758c9920b26504520631bf1027662d
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Vagrant DSC Plugin
2
2
 
3
- [Desired State Configuration](http://technet.microsoft.com/en-au/library/dn249912.aspx) provisioning plugin for Vagrant, enabling you to quickly configure & bootstrap a Windows Virtual Machine in a repeatable, reliable fashion.
3
+ [![Build Status](https://travis-ci.org/mefellows/vagrant-dsc.svg)](https://travis-ci.org/mefellows/vagrant-dsc)
4
+ [![Coverage Status](https://coveralls.io/repos/mefellows/vagrant-dsc/badge.png)](https://coveralls.io/r/mefellows/vagrant-dsc)
5
+ [![Gem Version](https://badge.fury.io/rb/vagrant-dsc.svg)](http://badge.fury.io/rb/vagrant-dsc)
6
+
7
+ [Desired State Configuration](http://technet.microsoft.com/en-au/library/dn249912.aspx) provisioning plugin for Vagrant, enabling you to quickly configure & bootstrap a Windows Virtual Machine in a repeatable, reliable fashion - the Vagrant way.
4
8
 
5
9
  .NET Devs - no more excuses...
6
10
 
@@ -14,29 +18,59 @@
14
18
 
15
19
  ## Usage
16
20
 
17
- In your Vagrantfile, add the following plugin:
21
+ In your Vagrantfile, add the following plugin and configure to your needs:
18
22
 
19
23
  ```ruby
20
24
  config.vm.provision "dsc" do |dsc|
21
- # The (Vagrantfile) relative path(s) to any folder containing DSC Resources
22
- dsc.manifests_path = ["manifests", "other_manifests"]
23
-
24
25
  # The path relative to `dsc.manifests_path` pointing to the Configuration file
25
- # Defaults to `default.ps1`
26
- dsc.manifest_file = "MyWebsite.ps1"
26
+ dsc.configuration_file = "MyWebsite.ps1"
27
+
28
+ # The Configuration Command to run. Assumed to be the same as the `dsc.configuration_file`
29
+ # (sans extension) if not provided.
30
+ dsc.configuration_name = "MyWebsite"
31
+
32
+ # Commandline arguments to the Configuration run
33
+ # Set of Parameters to pass to the DSC Configuration.
34
+ #
35
+ # To pass in flags, simply set the value to `nil`
36
+ dsc.configuration_params = {"machineName => "localhost", "-EnableDebug" => nil}
37
+
38
+ # Relative path to a folder containing a pre-generated MOF file.
39
+ #
40
+ # Path is relative to the folder containing the Vagrantfile.
41
+ #dsc.mof_path = "mof_output"
42
+
43
+ # Relative path to the folder containing the root Configuration manifest file.
44
+ # Defaults to 'manifests'.
45
+ #
46
+ # Path is relative to the folder containing the Vagrantfile.
47
+ # dsc.manifests_path = "manifests"
27
48
 
28
- # The Configuration Command to run. Assumed to be the same as the `dsc.manifest_file`
29
- # (sans extension) if not provided. In this case it would default to 'MyWebsite'
30
- dsc.command_name = "MyCustomCommandNameForWebsite"
49
+ # Set of module paths relative to the Vagrantfile dir.
50
+ #
51
+ # These paths are added to the DSC Configuration running
52
+ # environment to enable local modules to be addressed.
53
+ #
54
+ # @return [Array] Set of relative module paths.
55
+ #dsc.module_path = ["manifests", "modules"]
31
56
 
57
+ # The type of synced folders to use when sharing the data
58
+ # required for the provisioner to work properly.
32
59
  #
33
- dsc.parameters
60
+ # By default this will use the default synced folder type.
61
+ # For example, you can set this to "nfs" to use NFS synced folders.
62
+ #dsc.synced_folder_type = ""
63
+
64
+ # Temporary working directory on the guest machine.
65
+ #dsc.temp_dir = "/tmp/vagrant-dsc"
34
66
  end
35
67
  ```
36
68
 
37
- ## Features
69
+ ## Roadmap
38
70
 
39
- *
71
+ * Support DSC Pull Server provisioning
72
+ * Test (dry-run) a DSC Configuration Run with 'vagrant vagrant-dsc test'
73
+ * Support for non-Windows environments
40
74
 
41
75
  ### Supported Environments
42
76
 
@@ -73,14 +73,43 @@ SCRIPT
73
73
  dsc.module_path = ["manifests", "modules"]
74
74
 
75
75
  # The path relative to `dsc.manifests_path` pointing to the Configuration file
76
- dsc.manifest_file = "manifests/ContosoWebsite.ps1"
76
+ dsc.configuration_file = "manifests/MyWebsite.ps1"
77
77
 
78
- # The Configuration Command to run. Assumed to be the same as the `dsc.manifest_file`
78
+ # The Configuration Command to run. Assumed to be the same as the `dsc.configuration_file`
79
79
  # (sans extension) if not provided.
80
- # dsc.command_name = "ContosoWebsite"
80
+ dsc.configuration_name = "MyWebsite"
81
81
 
82
82
  # Commandline arguments to the Configuration run
83
- dsc.configuration_parameters = {}
84
- dsc.configuration_parameters[:machineName] = "localhost"
83
+ # Set of Parameters to pass to the DSC Configuration.
84
+ dsc.configuration_params = {[:machineName] => "localhost"}
85
+
86
+ # Relative path to a pre-generated MOF file.
87
+ #
88
+ # Path is relative to the folder containing the Vagrantfile.
89
+ #dsc.mof_file = "localhost.mof"
90
+
91
+ # Relative path to the folder containing the root Configuration manifest file.
92
+ # Defaults to 'manifests'.
93
+ #
94
+ # Path is relative to the folder containing the Vagrantfile.
95
+ # dsc.manifests_path = "manifests"
96
+
97
+ # Set of module paths relative to the Vagrantfile dir.
98
+ #
99
+ # These paths are added to the DSC Configuration running
100
+ # environment to enable local modules to be addressed.
101
+ #
102
+ # @return [Array] Set of relative module paths.
103
+ #dsc.module_path = []
104
+
105
+ # The type of synced folders to use when sharing the data
106
+ # required for the provisioner to work properly.
107
+ #
108
+ # By default this will use the default synced folder type.
109
+ # For example, you can set this to "nfs" to use NFS synced folders.
110
+ #dsc.synced_folder_type = ""
111
+
112
+ # Temporary working directory on the guest machine.
113
+ #dsc.temp_dir = "/tmp/vagrant-dsc"
85
114
  end
86
115
  end
@@ -1,4 +1,4 @@
1
- Configuration ContosoWebsite
1
+ Configuration MyWebsite
2
2
  {
3
3
  param ($MachineName)
4
4
 
@@ -3,54 +3,96 @@ require "log4r"
3
3
 
4
4
  module VagrantPlugins
5
5
  module DSC
6
+ # The "Configuration" represents a configuration of how the DSC
7
+ # provisioner should behave: data directories, working directory,
8
+ # DSC Manifests etc.
6
9
  class Config < Vagrant.plugin("2", :config)
7
10
  extend Vagrant::Util::Counter
8
11
 
9
- attr_accessor :facter
10
- attr_accessor :mof_file
11
- attr_accessor :manifest_file
12
+ # Set of Parameters to pass to the DSC Configuration.
13
+ #
14
+ # @return [Hash] Set of k/v parameters to pass to DSC.
15
+ attr_accessor :configuration_params
16
+
17
+ # Relative path to a folder, containing the pre-generated MOF file.
18
+ #
19
+ # Path is relative to the folder containing the Vagrantfile.
20
+ attr_accessor :mof_path
21
+
22
+ # Relative path to the DSC Configuration file.
23
+ #
24
+ # Path is relative to the folder containing the Vagrantfile.
25
+ attr_accessor :configuration_file
26
+
27
+ # Relative path to the folder containing the root Configuration manifest file.
28
+ # Defaults to 'manifests'.
29
+ #
30
+ # Path is relative to the folder containing the Vagrantfile.
12
31
  attr_accessor :manifests_path
32
+
33
+ # The name of the Configuration module
34
+ #
35
+ # Defaults to the basename of the "configuration_file"
36
+ # e.g. "Foo.ps1" becomes "Foo"
13
37
  attr_accessor :configuration_name
38
+
39
+ # Set of module paths relative to the Vagrantfile dir.
40
+ #
41
+ # These paths are added to the DSC Configuration running
42
+ # environment to enable local modules to be addressed.
43
+ #
44
+ # @return [Array] Set of relative module paths.
14
45
  attr_accessor :module_path
15
- attr_accessor :options
46
+
47
+ # The type of synced folders to use when sharing the data
48
+ # required for the provisioner to work properly.
49
+ #
50
+ # By default this will use the default synced folder type.
51
+ # For example, you can set this to "nfs" to use NFS synced folders.
16
52
  attr_accessor :synced_folder_type
53
+
54
+ # Temporary working directory on the guest machine.
17
55
  attr_accessor :temp_dir
18
- attr_accessor :working_directory
56
+
57
+ # Fully qualified path to the configuration file.
58
+ #
59
+ # Do not override this.
60
+ attr_accessor :expanded_configuration_file
19
61
 
20
62
  def initialize
21
63
  super
22
64
 
23
- @manifest_file = UNSET_VALUE
24
- @manifests_path = UNSET_VALUE
25
- @configuration_name = UNSET_VALUE
26
- @mof_file = UNSET_VALUE
27
- @module_path = UNSET_VALUE
28
- @options = []
29
- @facter = {}
30
- @synced_folder_type = UNSET_VALUE
31
- @temp_dir = UNSET_VALUE
32
- @working_directory = UNSET_VALUE
33
-
65
+ @configuration_file = UNSET_VALUE
66
+ @manifests_path = UNSET_VALUE
67
+ @configuration_name = UNSET_VALUE
68
+ @mof_path = UNSET_VALUE
69
+ @module_path = UNSET_VALUE
70
+ @configuration_params = {}
71
+ @synced_folder_type = UNSET_VALUE
72
+ @temp_dir = UNSET_VALUE
34
73
  @logger = Log4r::Logger.new("vagrant::vagrant_dsc")
35
74
  end
36
75
 
37
- def merge(other)
38
- super.tap do |result|
39
- result.facter = @facter.merge(other.facter)
40
- end
41
- end
42
-
76
+ # Final step of the Configuration lifecyle prior to
77
+ # validation.
78
+ #
79
+ # Ensures all attributes are set to defaults if not provided.
43
80
  def finalize!
44
81
  super
45
82
 
46
- @manifest_file = "default.ps1" if @manifest_file == UNSET_VALUE
83
+ # Null checks
84
+ @configuration_file = "default.ps1" if @configuration_file == UNSET_VALUE
47
85
  @module_path = nil if @module_path == UNSET_VALUE
48
86
  @synced_folder_type = nil if @synced_folder_type == UNSET_VALUE
49
87
  @temp_dir = nil if @temp_dir == UNSET_VALUE
50
- @mof_file = nil if @mof_file == UNSET_VALUE
51
- @working_directory = nil if @working_directory == UNSET_VALUE
52
- @configuration_name = File.basename(@manifest_file, File.extname(@manifest_file)) if @configuration_name == UNSET_VALUE
53
- @manifests_path = File.dirname(@manifest_file)
88
+ @mof_path = nil if @mof_path == UNSET_VALUE
89
+ @configuration_name = File.basename(@configuration_file, File.extname(@configuration_file)) if @configuration_name == UNSET_VALUE
90
+ @manifests_path = File.dirname(@configuration_file) if @manifests_path == UNSET_VALUE
91
+
92
+ # Can't supply them both!
93
+ if (@configuration_file != nil && @mof_path != nil)
94
+ raise DSCError, :manifest_and_mof_provided
95
+ end
54
96
 
55
97
  # Set a default temp dir that has an increasing counter so
56
98
  # that multiple DSC definitions won't overwrite each other
@@ -62,6 +104,9 @@ module VagrantPlugins
62
104
 
63
105
  # Returns the module paths as an array of paths expanded relative to the
64
106
  # root path.
107
+ #
108
+ # @param [String|Array] root_path The relative path to expand module paths against.
109
+ # @return [Array] Set of fully qualified paths to the modules directories.
65
110
  def expanded_module_paths(root_path)
66
111
  return [] if !module_path
67
112
 
@@ -70,13 +115,17 @@ module VagrantPlugins
70
115
  paths = module_path
71
116
  paths = [paths] if !paths.is_a?(Array)
72
117
  paths.map do |path|
73
- Pathname.new(path).expand_path(root_path)
118
+ Pathname.new(path).expand_path(root_path).to_s
74
119
  end
75
120
  end
76
121
 
122
+ # Validate configuration and return a hash of errors.
77
123
  #
78
- # Validate configuration
124
+ # Does not check that DSC itself is properly configured, which is performed
125
+ # at run-time.
79
126
  #
127
+ # @param [Machine] The current {Machine}
128
+ # @return [Hash] Any errors or {} if no errors found
80
129
  def validate(machine)
81
130
  @logger.info("==> Configurin' DSC man!")
82
131
  errors = _detected_errors
@@ -85,20 +134,22 @@ module VagrantPlugins
85
134
  this_expanded_module_paths = expanded_module_paths(machine.env.root_path)
86
135
 
87
136
  # Manifest file validation
137
+ this_expanded_module_paths.each do |path|
138
+ errors << I18n.t("vagrant_dsc.errors.module_path_missing", path: path) if !Pathname.new(path).expand_path(machine.env.root_path).directory?
139
+ end
140
+
141
+ expanded_path = Pathname.new(manifests_path).
142
+ expand_path(machine.env.root_path)
143
+
144
+ if !expanded_path.directory?
145
+ errors << I18n.t("vagrant_dsc.errors.manifests_path_missing",
146
+ path: expanded_path.to_s)
147
+ end
88
148
 
89
- if manifests_path[0].to_sym == :host
90
- expanded_path = Pathname.new(manifests_path[1]).
91
- expand_path(machine.env.root_path)
92
- if !expanded_path.directory?
93
- errors << I18n.t("vagrant_dsc.errors.manifests_path_missing",
94
- path: expanded_path.to_s)
95
- else
96
- expanded_manifest_file = expanded_path.join(manifest_file)
97
- if !expanded_manifest_file.file? && !expanded_manifest_file.directory?
98
- errors << I18n.t("vagrant_dsc.errors.manifest_missing",
99
- manifest: expanded_manifest_file.to_s)
100
- end
101
- end
149
+ @expanded_configuration_file = expanded_path.join(File.basename(configuration_file))
150
+ if !expanded_configuration_file.file? && !expanded_configuration_file.directory?
151
+ errors << I18n.t("vagrant_dsc.errors.manifest_missing",
152
+ manifest: expanded_configuration_file.to_s)
102
153
  end
103
154
 
104
155
  { "dsc provisioner" => errors }
@@ -30,3 +30,9 @@ en:
30
30
  "Path to DSC Manifest folder does not exist: %{path}"
31
31
  manifest_missing: |-
32
32
  "Path to DSC Manifest does not exist: %{manifest}"
33
+ manifest_and_mof_provided: |-
34
+ "Cannot provide configuration_file and mof_path at the same time. Please provide only one of the two."
35
+ unsupported_operation: |-
36
+ "Operation unsupported / not-yet implemented: %{operation}"
37
+ absolute_module_path: |-
38
+ "Absolute 'module_path' not allowed. Please provide a path relative to your Vagrantfile."
@@ -5,8 +5,8 @@ module VagrantPlugins
5
5
  class Plugin < Vagrant.plugin("2")
6
6
  name "DSC"
7
7
  description <<-DESC
8
- Provides support for provisioning your virtual machines with
9
- DSC either using a local `DSC` Configuration or a DSC server.
8
+ Provides support for provisioning your virtual machines with
9
+ DSC either using a local `DSC` Configuration or a DSC server.
10
10
  DESC
11
11
 
12
12
  config(:dsc, :provisioner) do
@@ -3,28 +3,47 @@ require 'erb'
3
3
 
4
4
  module VagrantPlugins
5
5
  module DSC
6
+ # DSC Errors namespace, including setup of locale-based error messages.
6
7
  class DSCError < Vagrant::Errors::VagrantError
7
8
  error_namespace("vagrant_dsc.errors")
8
9
  I18n.load_path << File.expand_path("locales/en.yml", File.dirname(__FILE__))
9
10
  end
10
-
11
+ class DSCUnsupportedOperation < DSCError
12
+ error_key(:unsupported_operation)
13
+ end
14
+
15
+ # DSC Provisioner Plugin.
16
+ #
17
+ # Runs the [Desired State Configuration](http://technet.microsoft.com/en-au/library/dn249912.aspx) system
18
+ # on a guest Virtual Machine, enabling you to quickly configure & bootstrap a Windows Virtual Machine in a repeatable,
19
+ # reliable fashion - the Vagrant way.
11
20
  class Provisioner < Vagrant.plugin("2", :provisioner)
12
- POWERSHELL_VERSION = 5
21
+ PowerShell_VERSION = 4
22
+
23
+ # Default path for storing the transient script runner
24
+ # This should be removed in cleanup
13
25
  DSC_GUEST_RUNNER_PATH = "c:/tmp/vagrant-dsc-runner.ps1"
14
26
 
27
+ # Constructs the Provisioner Plugin.
28
+ #
29
+ # @param [Machine] machine The guest machine that is to be provisioned.
30
+ # @param [Config] config The Configuration object used by the Provisioner.
31
+ # @returns Provisioner
15
32
  def initialize(machine, config)
16
33
  super
17
34
 
18
35
  @logger = Log4r::Logger.new("vagrant::provisioners::dsc")
19
36
  end
20
37
 
38
+ # Configures the Provisioner.
39
+ #
40
+ # @param [Config] root_config The default configuration from the Vagrant hierarchy.
21
41
  def configure(root_config)
22
- @logger.info("==> Configuring DSC man!")
42
+ @logger.info("==> Configuring DSC")
23
43
 
24
44
  # Calculate the paths we're going to use based on the environment
25
45
  root_path = @machine.env.root_path
26
46
  @expanded_module_paths = @config.expanded_module_paths(root_path)
27
- @manifest_file = File.join(manifests_guest_path, @config.manifest_file)
28
47
 
29
48
  # Setup the module paths
30
49
  @module_paths = []
@@ -38,6 +57,7 @@ module VagrantPlugins
38
57
 
39
58
  # Share the manifests directory with the guest
40
59
  @logger.info("==> Sharing manifest #{File.expand_path(@config.manifests_path, root_path)} | #{manifests_guest_path} | #{folder_opts}")
60
+
41
61
  root_config.vm.synced_folder(
42
62
  File.expand_path(@config.manifests_path, root_path),
43
63
  manifests_guest_path, folder_opts)
@@ -49,6 +69,7 @@ module VagrantPlugins
49
69
  end
50
70
  end
51
71
 
72
+ # Provision the guest machine with DSC.
52
73
  def provision
53
74
  @logger.info("==> Provisioning DSC man! #{Vagrant.source_root}")
54
75
 
@@ -75,26 +96,35 @@ module VagrantPlugins
75
96
 
76
97
  verify_dsc
77
98
 
78
- generate_dsc_runner_script
79
-
80
- run_dsc_apply
99
+ run_dsc_apply(generate_dsc_runner_script)
100
+ end
81
101
 
102
+ # Cleanup after a destroy action.
103
+ #
104
+ # This is the method called when destroying a machine that allows
105
+ # for any state related to the machine created by the provisioner
106
+ # to be cleaned up.
107
+ def cleanup
108
+ # Remove temp files? Or is this ONLY called in destroy (in which case those files will go anyway...)
82
109
  end
83
110
 
111
+ # Local path (guest path) to the manifests directory.
84
112
  def manifests_guest_path
85
113
  File.join(config.temp_dir, config.manifests_path)
86
114
  end
87
115
 
116
+ # Verify that a current version of WMF/Powershell is enabled on the guest.
88
117
  def verify_dsc
89
118
  verify_binary("Start-DscConfiguration")
90
119
 
91
120
  # Confirm WMF 4.0+ in $PSVersionTable
92
121
  @machine.communicate.test(
93
- "(($PSVersionTable | ConvertTo-json | ConvertFrom-Json).PSVersion.Major) -ge #{POWERSHELL_VERSION} ",
122
+ "(($PSVersionTable | ConvertTo-json | ConvertFrom-Json).PSVersion.Major) -ge #{PowerShell_VERSION}",
94
123
  error_class: DSCError,
95
- error_key: :dsc_incorrect_powershell_version )
124
+ error_key: :dsc_incorrect_PowerShell_version )
96
125
  end
97
126
 
127
+ # Verify the DSC binary is executable on the guest machine.
98
128
  def verify_binary(binary)
99
129
  @machine.communicate.sudo(
100
130
  "which #{binary}",
@@ -105,25 +135,40 @@ module VagrantPlugins
105
135
 
106
136
  # Install and Configure DSC where possible.
107
137
  #
138
+ # Operation is current unsupported, but is likely to be enabled
139
+ # as a flag when the plugin detects an unsupported OS.
108
140
  def install_dsc
141
+ # raise DSCError, I18n.t("vagrant_dsc.errors.manifest_missing", operation: "install_dsc")
142
+ raise DSCUnsupportedOperation, :operation => "install_dsc"
143
+ # Install chocolatey
109
144
 
110
145
  # Ensure .NET 4.5 installed
111
146
 
112
147
  # Ensure WMF 4.0 is installed
113
-
114
148
  end
115
149
 
116
- # Generates a Powershell DSC runner script from an ERB template
150
+ # Generates a PowerShell DSC runner script from an ERB template
151
+ #
152
+ # @return [String] The interpolated PowerShell script.
117
153
  def generate_dsc_runner_script
118
154
  path = File.expand_path("../templates/runner.ps1", __FILE__)
155
+
119
156
  script = Vagrant::Util::TemplateRenderer.render(path, options: {
120
- config: config,
121
- module_paths: @module_paths,
122
- manifest_file: config.manifest_file,
123
- configuration_name: config.configuration_name,
124
- temp_path: config.temp_dir,
125
- parameters: config.parameters.map { |k,v|}.join,
157
+ config: @config,
158
+ module_paths: @module_paths.map { |k,v| v }.join(";"),
159
+ mof_path: @config.mof_path,
160
+ configuration_file: @config.configuration_file,
161
+ configuration_name: @config.configuration_name,
162
+ temp_path: @config.temp_dir,
163
+ parameters: @config.configuration_params.map { |k,v| "#{k}" + (!v.nil? ? " \"#{v}\"": '') }.join(" ")
126
164
  })
165
+ end
166
+
167
+ # Writes the PowerShell DSC runner script to a location on the guest.
168
+ #
169
+ # @param [String] script The PowerShell DSC runner script.
170
+ # @return [String] the Path to the uploaded location on the guest machine.
171
+ def write_dsc_runner_script(script)
127
172
  guest_script_path = DSC_GUEST_RUNNER_PATH
128
173
  file = Tempfile.new(["vagrant-dsc-runner", "ps1"])
129
174
  begin
@@ -138,29 +183,28 @@ module VagrantPlugins
138
183
  guest_script_path
139
184
  end
140
185
 
186
+ # Runs the DSC Configuration over the guest machine.
187
+ #
188
+ # Expects
141
189
  def run_dsc_apply
142
190
 
191
+ # Check the DSC_GUEST_RUNNER_PATH exists?
192
+
143
193
  # Set up Configuration arguments (hostname, manifest/module location, error levels ...)
144
194
 
145
195
  # Where are the modules?
146
196
 
147
197
  # Where is the manifest
148
198
 
149
- # Setup $env:PSModulePath for execution env.
150
-
151
- # Integrator -ConfigurationData "$SetupPath\Configuration\Development.psd1" -OutputPath $StagingPath -BasePath $AppBasePath
152
-
153
199
  # TODO: Get a counter in here in case of multiple runs
154
200
 
155
- # Apply configuration/parameters to DSC Runner
156
-
157
201
  # Import starting point configuration into scope
158
202
 
159
- command = ".\"#{DSC_GUEST_RUNNER_PATH}\""
203
+ command = ".\\'#{DSC_GUEST_RUNNER_PATH}'"
160
204
 
161
205
  @machine.ui.info(I18n.t(
162
206
  "vagrant_dsc.running_dsc",
163
- manifest: config.manifest_file))
207
+ manifest: config.configuration_file))
164
208
 
165
209
  opts = {
166
210
  elevated: true,
@@ -175,6 +219,8 @@ module VagrantPlugins
175
219
  end
176
220
  end
177
221
 
222
+ # Verify that the shared folders have been properly configured
223
+ # on the guest machine.
178
224
  def verify_shared_folders(folders)
179
225
  folders.each do |folder|
180
226
  @logger.info("Checking for shared folder: #{folder}")
@@ -184,9 +230,10 @@ module VagrantPlugins
184
230
  end
185
231
  end
186
232
 
233
+ # If on using WinRM, we can assume we are on Windows
187
234
  def windows?
188
235
  @machine.config.vm.communicator == :winrm
189
236
  end
190
237
  end
191
238
  end
192
- end
239
+ end
@@ -1,24 +1,32 @@
1
1
  #
2
- # DSC Runner Script.
3
- # Bootstraps the DSC environment, configuration and runs the DSC Configuration.
2
+ # DSC Runner.
3
+ #
4
+ # Bootstraps the DSC environment, sets up configuration data
5
+ # and runs the DSC Configuration.
6
+ #
4
7
  #
5
8
 
6
- # Set the local PowerShell module environment path
7
- <% options[:module_paths].each do |host, guest| %>
8
- echo "Adding to path: <%= guest %>"
9
- $env:PSModulePath="<%= guest %>;${env:PSModulePath}"
9
+ # Set the local PowerShell Module environment path
10
+ <% if options[:module_paths] %>
11
+ echo "Adding to path: <%= options[:module_paths] %>"
12
+ $env:PSModulePath="<%= options[:module_paths] %>;${env:PSModulePath}"
10
13
  <% end %>
11
14
 
15
+ $script = $(Join-Path "<%= options[:temp_path] %>" "<%= options[:configuration_file] %>")
12
16
  echo "PSModulePath Configured: ${env:PSModulePath}"
13
- echo "Running Configuration file: <%= options[:manifest_file_path] %>"
17
+ echo "Running Configuration file: ${script}"
14
18
 
19
+ # Generate the MOF file, only if a MOF path not already provided.
20
+ <% if options[:mof_path] == nil %>
15
21
  # Import the Manifest
16
- . $(Join-Path "<%= options[:temp_path] %>" "<%= options[:manifest_file] %>")
22
+ . $script
17
23
 
18
- # Generate the MOF file
19
24
  cd "<%= options[:temp_path] %>"
20
25
  $StagingPath = $(Join-Path "<%= options[:temp_path] %>" "staging")
21
- <%= options[:configuration_name] %> -MachineName "localhost" -OutputPath $StagingPath <%= options[:configuration_parameters] %>
26
+ <%=options[:configuration_name]%> -MachineName "localhost" -OutputPath $StagingPath <%= options[:parameters] %>
27
+ <% else %>
28
+ $StagingPath = "<%= options[:mof_path] %>"
29
+ <% end %>
22
30
 
23
31
  # Start a DSC Configuration run
24
32
  Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Dsc
3
- VERSION = "0.0.1"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end