vagrant-dsc 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/development/Vagrantfile +20 -13
- data/development/manifests/MyConfig.psd1 +10 -0
- data/development/manifests/MyWebsite.ps1 +16 -8
- data/development/modules/MyWebapp/DSCResources/SimpleWebsite/SimpleWebsite.schema.psm1 +32 -16
- data/lib/vagrant-dsc/config.rb +59 -25
- data/lib/vagrant-dsc/locales/en.yml +2 -0
- data/lib/vagrant-dsc/provisioner.rb +1 -0
- data/lib/vagrant-dsc/templates/runner.ps1.erb +1 -0
- data/lib/vagrant-dsc/version.rb +1 -1
- data/spec/provisioner/config_spec.rb +35 -14
- data/spec/provisioner/provisioner_spec.rb +77 -13
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 407c2cc8f7c8786fe7628c4894ed967be86d05aa
|
4
|
+
data.tar.gz: 4f093c1e28adb46cdbc804ad8cc4a329d03f9008
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 568a9dfdb800956ad3724a3a2582a3a7785310142ac139273577cc3643475fbf02d478c13ca7056b9aabffc746a54d04253e33f580327892b50830d4298cd482
|
7
|
+
data.tar.gz: 7f063bd5ce7baa8b876296306d67da778a9b9597be5a3ccae045a2f4152b6e463e19d9d379b83686dd845daff76118055afc9c4d0c933b90e7293e8bf49f1dbe
|
data/development/Vagrantfile
CHANGED
@@ -2,8 +2,11 @@
|
|
2
2
|
# vi: set ft=ruby :
|
3
3
|
|
4
4
|
$shell_script = <<SCRIPT
|
5
|
-
(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')))>$null 2>&1
|
6
|
-
choco install seek-dsc
|
5
|
+
#(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')))>$null 2>&1
|
6
|
+
#choco install seek-dsc
|
7
|
+
(New-Object System.Net.WebClient).DownloadFile('https://gallery.technet.microsoft.com/scriptcenter/xWebAdministration-Module-3c8bb6be/file/131367/3/xWebAdministration_1.3.2.zip','c:\\xwebadmin.zip')
|
8
|
+
choco install 7zip
|
9
|
+
7za.exe x -y C:\\xwebadmin.zip -o'C:\\Program Files\\WindowsPowerShell\\Modules'
|
7
10
|
Get-DSCResource
|
8
11
|
SCRIPT
|
9
12
|
|
@@ -16,17 +19,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
16
19
|
# please see the online documentation at vagrantup.com.
|
17
20
|
|
18
21
|
# Every Vagrant virtual environment requires a box to build off of.
|
19
|
-
#config.vm.box = "
|
20
|
-
config.vm.
|
22
|
+
# config.vm.box = "mfellows/windows2012r2"
|
23
|
+
# config.vm.box_version = "1.0.1"
|
24
|
+
config.vm.box = "windows2012r2"
|
21
25
|
|
22
26
|
config.vm.guest = :windows
|
23
27
|
config.vm.communicator = "winrm"
|
24
28
|
|
25
29
|
config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
|
26
30
|
config.vm.network :forwarded_port, guest: 80, host: 8000, id: "web" # Port forward for IIS
|
27
|
-
|
31
|
+
config.vm.network :forwarded_port, guest: 443, host: 8443, id: "ssl" # Port forward for SSL IIS
|
28
32
|
config.vm.network :forwarded_port, guest: 22, host: 9222, id: "ssh" # Port forward for SSL IIS
|
29
|
-
|
33
|
+
|
30
34
|
config.vm.provider "virtualbox" do |v|
|
31
35
|
v.gui = true
|
32
36
|
end
|
@@ -46,24 +50,22 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
46
50
|
# environment to enable local modules to be addressed.
|
47
51
|
#
|
48
52
|
# @return [Array] Set of relative module paths.
|
49
|
-
# dsc.module_path = ["manifests", "modules"]
|
50
53
|
dsc.module_path = ["modules"]
|
51
54
|
|
52
55
|
# The path relative to `dsc.manifests_path` pointing to the Configuration file
|
53
56
|
dsc.configuration_file = "MyWebsite.ps1"
|
54
57
|
|
58
|
+
# The path relative to Vagrantfile pointing to the Configuration Data file
|
59
|
+
dsc.configuration_data_file = "manifests/MyConfig.psd1"
|
60
|
+
|
55
61
|
# The Configuration Command to run. Assumed to be the same as the `dsc.configuration_file`
|
56
62
|
# (sans extension) if not provided.
|
57
63
|
dsc.configuration_name = "MyWebsite"
|
58
64
|
|
59
|
-
# Commandline arguments to the Configuration run
|
60
|
-
# Set of Parameters to pass to the DSC Configuration.
|
61
|
-
dsc.configuration_params = {"-MachineName" => "localhost"}
|
62
|
-
|
63
65
|
# Relative path to a pre-generated MOF file.
|
64
66
|
#
|
65
67
|
# Path is relative to the folder containing the Vagrantfile.
|
66
|
-
#dsc.mof_path = "mof"
|
68
|
+
# dsc.mof_path = "mof"
|
67
69
|
|
68
70
|
# Relative path to the folder containing the root Configuration manifest file.
|
69
71
|
# Defaults to 'manifests'.
|
@@ -71,12 +73,17 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
71
73
|
# Path is relative to the folder containing the Vagrantfile.
|
72
74
|
dsc.manifests_path = "manifests"
|
73
75
|
|
76
|
+
# Commandline arguments to the Configuration run
|
77
|
+
#
|
78
|
+
# Set of Parameters to pass to the DSC Configuration.
|
79
|
+
dsc.configuration_params = {"-MachineName" => "localhost"}
|
80
|
+
|
74
81
|
# The type of synced folders to use when sharing the data
|
75
82
|
# required for the provisioner to work properly.
|
76
83
|
#
|
77
84
|
# By default this will use the default synced folder type.
|
78
85
|
# For example, you can set this to "nfs" to use NFS synced folders.
|
79
|
-
#dsc.synced_folder_type = ""
|
86
|
+
# dsc.synced_folder_type = ""
|
80
87
|
|
81
88
|
# Temporary working directory on the guest machine.
|
82
89
|
# dsc.temp_dir = "c:/tmp/vagrant-dsc"
|
@@ -2,8 +2,8 @@ Configuration MyWebsite
|
|
2
2
|
{
|
3
3
|
param ($MachineName)
|
4
4
|
|
5
|
-
Import-DscResource -Module cWebAdministration
|
6
5
|
Import-DscResource -Module MyWebapp
|
6
|
+
Import-DscResource -Module cNetworking
|
7
7
|
|
8
8
|
Node $MachineName
|
9
9
|
{
|
@@ -12,15 +12,23 @@ Configuration MyWebsite
|
|
12
12
|
Ensure = "Present"
|
13
13
|
Name = "Web-Server"
|
14
14
|
}
|
15
|
-
|
15
|
+
|
16
|
+
WindowsFeature IISManagerFeature
|
17
|
+
{
|
18
|
+
Ensure = "Present"
|
19
|
+
Name = "Web-Mgmt-Tools"
|
20
|
+
}
|
21
|
+
|
22
|
+
cFirewallRule webFirewall
|
16
23
|
{
|
17
|
-
Name = "
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
Name = "WebFirewallOpen"
|
25
|
+
Direction = "Inbound"
|
26
|
+
LocalPort = "80"
|
27
|
+
Protocol = "TCP"
|
28
|
+
Action = "Allow"
|
29
|
+
Ensure = "Present"
|
22
30
|
}
|
23
|
-
|
31
|
+
|
24
32
|
SimpleWebsite sWebsite
|
25
33
|
{
|
26
34
|
WebAppPath = "c:\my-new-webapp"
|
@@ -7,25 +7,41 @@
|
|
7
7
|
[HashTable]$AuthenticationInfo = @{Anonymous = "true"; Basic = "false"; Digest = "false"; Windows = "false"}
|
8
8
|
)
|
9
9
|
|
10
|
-
Import-DscResource -Module cWebAdministration
|
10
|
+
# Import-DscResource -Module cWebAdministration
|
11
|
+
Import-DscResource -Module xWebAdministration
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
{
|
15
|
-
Ensure =
|
16
|
-
Name =
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
{
|
21
|
-
Anonymous = $AuthenticationInfo.Anonymous
|
22
|
-
Basic = $AuthenticationInfo.Basic
|
23
|
-
Digest = $AuthenticationInfo.Digest
|
24
|
-
Windows = $AuthenticationInfo.Windows
|
25
|
-
}
|
26
|
-
DependsOn = '[File]website'
|
13
|
+
# Stop the default website
|
14
|
+
xWebsite DefaultSite
|
15
|
+
{
|
16
|
+
Ensure = "Present"
|
17
|
+
Name = "Default Web Site"
|
18
|
+
State = "Stopped"
|
19
|
+
PhysicalPath = "C:\inetpub\wwwroot"
|
20
|
+
DependsOn = "[File]websiteIndex"
|
27
21
|
}
|
28
22
|
|
23
|
+
# Create a Web Application Pool
|
24
|
+
xWebAppPool NewWebAppPool
|
25
|
+
{
|
26
|
+
Name = "${WebAppName}AppPool"
|
27
|
+
Ensure = "Present"
|
28
|
+
State = "Started"
|
29
|
+
}
|
30
|
+
|
31
|
+
#Create a New Website with Port
|
32
|
+
xWebSite NewWebSite
|
33
|
+
{
|
34
|
+
Name = $WebAppName
|
35
|
+
Ensure = "Present"
|
36
|
+
BindingInfo = MSFT_xWebBindingInformation
|
37
|
+
{
|
38
|
+
Port = 80
|
39
|
+
}
|
40
|
+
PhysicalPath = $WebAppPath
|
41
|
+
State = "Started"
|
42
|
+
DependsOn = @("[xWebAppPool]NewWebAppPool")
|
43
|
+
}
|
44
|
+
|
29
45
|
File websiteIndex
|
30
46
|
{
|
31
47
|
Ensure = "Present"
|
data/lib/vagrant-dsc/config.rb
CHANGED
@@ -24,6 +24,13 @@ module VagrantPlugins
|
|
24
24
|
# Path is relative to the folder containing the Vagrantfile.
|
25
25
|
attr_accessor :configuration_file
|
26
26
|
|
27
|
+
# Relative path to the DSC Configuration Data file.
|
28
|
+
#
|
29
|
+
# Configuration data is used to parameterise the configuration_file.
|
30
|
+
#
|
31
|
+
# Path is relative to the folder containing the Vagrantfile.
|
32
|
+
attr_accessor :configuration_data_file
|
33
|
+
|
27
34
|
# Relative path to the folder containing the root Configuration manifest file.
|
28
35
|
# Defaults to 'manifests'.
|
29
36
|
#
|
@@ -59,17 +66,23 @@ module VagrantPlugins
|
|
59
66
|
# Do not override this.
|
60
67
|
attr_accessor :expanded_configuration_file
|
61
68
|
|
69
|
+
# Fully qualified path to the configuration data file.
|
70
|
+
#
|
71
|
+
# Do not override this.
|
72
|
+
attr_accessor :expanded_configuration_data_file
|
73
|
+
|
62
74
|
def initialize
|
63
75
|
super
|
64
76
|
|
65
|
-
@configuration_file
|
66
|
-
@
|
67
|
-
@
|
68
|
-
@
|
69
|
-
@
|
70
|
-
@
|
71
|
-
@
|
72
|
-
@
|
77
|
+
@configuration_file = UNSET_VALUE
|
78
|
+
@configuration_data_file = UNSET_VALUE
|
79
|
+
@manifests_path = UNSET_VALUE
|
80
|
+
@configuration_name = UNSET_VALUE
|
81
|
+
@mof_path = UNSET_VALUE
|
82
|
+
@module_path = UNSET_VALUE
|
83
|
+
@configuration_params = {}
|
84
|
+
@synced_folder_type = UNSET_VALUE
|
85
|
+
@temp_dir = UNSET_VALUE
|
73
86
|
@logger = Log4r::Logger.new("vagrant::vagrant_dsc")
|
74
87
|
end
|
75
88
|
|
@@ -81,13 +94,14 @@ module VagrantPlugins
|
|
81
94
|
super
|
82
95
|
|
83
96
|
# Null checks
|
84
|
-
@configuration_file
|
85
|
-
@
|
86
|
-
@
|
87
|
-
@
|
88
|
-
@
|
89
|
-
@
|
90
|
-
@
|
97
|
+
@configuration_file = "default.ps1" if @configuration_file == UNSET_VALUE
|
98
|
+
@configuration_data_file = nil if @configuration_data_file == UNSET_VALUE
|
99
|
+
@module_path = nil if @module_path == UNSET_VALUE
|
100
|
+
@synced_folder_type = nil if @synced_folder_type == UNSET_VALUE
|
101
|
+
@temp_dir = nil if @temp_dir == UNSET_VALUE
|
102
|
+
@mof_path = nil if @mof_path == UNSET_VALUE
|
103
|
+
@configuration_name = File.basename(@configuration_file, File.extname(@configuration_file)) if @configuration_name == UNSET_VALUE
|
104
|
+
@manifests_path = File.dirname(@configuration_file) if @manifests_path == UNSET_VALUE
|
91
105
|
|
92
106
|
# Can't supply them both!
|
93
107
|
if (@configuration_file != nil && @mof_path != nil)
|
@@ -127,29 +141,49 @@ module VagrantPlugins
|
|
127
141
|
# @param [Machine] The current {Machine}
|
128
142
|
# @return [Hash] Any errors or {} if no errors found
|
129
143
|
def validate(machine)
|
130
|
-
@logger.info("==>
|
144
|
+
@logger.info("==> Configuring DSC")
|
131
145
|
errors = _detected_errors
|
132
146
|
|
133
147
|
# Calculate the manifests and module paths based on env
|
134
|
-
|
148
|
+
local_expanded_module_paths = expanded_module_paths(machine.env.root_path)
|
135
149
|
|
136
150
|
# Manifest file validation
|
137
|
-
|
151
|
+
local_expanded_module_paths.each do |path|
|
138
152
|
errors << I18n.t("vagrant_dsc.errors.module_path_missing", path: path) if !Pathname.new(path).expand_path(machine.env.root_path).directory?
|
139
153
|
end
|
140
154
|
|
141
|
-
|
142
|
-
expand_path(machine.env.root_path)
|
155
|
+
host_manifest_path = Pathname.new(manifests_path).expand_path(machine.env.root_path)
|
143
156
|
|
144
|
-
if !
|
157
|
+
if !host_manifest_path.directory?
|
145
158
|
errors << I18n.t("vagrant_dsc.errors.manifests_path_missing",
|
146
|
-
path:
|
159
|
+
path: host_manifest_path.to_s)
|
147
160
|
end
|
148
161
|
|
149
|
-
|
150
|
-
|
162
|
+
# Path to manifest file on the host machine must exist
|
163
|
+
host_expanded_configuration_file = host_manifest_path.join(File.basename(configuration_file))
|
164
|
+
if !host_expanded_configuration_file.file? && !host_expanded_configuration_file.directory?
|
151
165
|
errors << I18n.t("vagrant_dsc.errors.manifest_missing",
|
152
|
-
manifest:
|
166
|
+
manifest: host_expanded_configuration_file.to_s)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Set absolute path to manifest file on the guest
|
170
|
+
@expanded_configuration_file = Pathname.new(File.dirname(configuration_file)).expand_path(temp_dir).join(File.basename(configuration_file))
|
171
|
+
|
172
|
+
# Check path of the configuration data file on host
|
173
|
+
if configuration_data_file != nil
|
174
|
+
|
175
|
+
host_expanded_path = Pathname.new(File.dirname(configuration_data_file)).expand_path(machine.env.root_path)
|
176
|
+
expanded_host_configuration_data_file = host_expanded_path.join(File.basename(configuration_data_file))
|
177
|
+
|
178
|
+
if !expanded_host_configuration_data_file.file? && !expanded_host_configuration_data_file.directory?
|
179
|
+
errors << I18n.t("vagrant_dsc.errors.configuration_data_missing",
|
180
|
+
path: expanded_host_configuration_data_file.to_s)
|
181
|
+
end
|
182
|
+
|
183
|
+
@expanded_configuration_data_file = Pathname.new(File.dirname(configuration_data_file)).expand_path(temp_dir).join(File.basename(configuration_data_file))
|
184
|
+
|
185
|
+
# Add -ConfigurationData flag to parameters
|
186
|
+
configuration_params["-ConfigurationData"] = expanded_configuration_data_file if @expanded_configuration_data_file != nil
|
153
187
|
end
|
154
188
|
|
155
189
|
{ "dsc provisioner" => errors }
|
@@ -30,6 +30,8 @@ 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
|
+
configuration_data_missing: |-
|
34
|
+
"Path to DSC Configuration Data file does not exist: %{path}"
|
33
35
|
manifest_and_mof_provided: |-
|
34
36
|
"Cannot provide configuration_file and mof_path at the same time. Please provide only one of the two."
|
35
37
|
unsupported_operation: |-
|
@@ -160,6 +160,7 @@ module VagrantPlugins
|
|
160
160
|
module_paths: @module_paths.map { |k,v| v }.join(";"),
|
161
161
|
mof_path: @config.mof_path,
|
162
162
|
configuration_file: @config.configuration_file,
|
163
|
+
configuration_data_file: @config.expanded_configuration_data_file,
|
163
164
|
configuration_file_path: "#{@config.manifests_path}/#{File.basename @config.configuration_file}",
|
164
165
|
configuration_name: @config.configuration_name,
|
165
166
|
manifests_path: @config.manifests_path,
|
data/lib/vagrant-dsc/version.rb
CHANGED
@@ -29,16 +29,17 @@ describe VagrantPlugins::DSC::Config do
|
|
29
29
|
|
30
30
|
before { subject.finalize! }
|
31
31
|
|
32
|
-
its("configuration_file")
|
33
|
-
its("
|
34
|
-
its("
|
35
|
-
its("
|
36
|
-
its("
|
37
|
-
its("
|
38
|
-
its("
|
39
|
-
its("
|
40
|
-
its("
|
41
|
-
its("
|
32
|
+
its("configuration_file") { expect = "default.ps1" }
|
33
|
+
its("configuration_data_file") { expect be_nil }
|
34
|
+
its("manifests_path") { expect = "." }
|
35
|
+
its("configuration_name") { expect = "default" }
|
36
|
+
its("mof_path") { expect be_nil }
|
37
|
+
its("module_path") { expect be_nil }
|
38
|
+
its("options") { expect = [] }
|
39
|
+
its("configuration_params") { expect = {} }
|
40
|
+
its("synced_folder_type") { expect be_nil }
|
41
|
+
its("temp_dir") { expect match /^\/tmp\/vagrant-dsc-*/ }
|
42
|
+
its("working_directory") { expect be_nil }
|
42
43
|
end
|
43
44
|
|
44
45
|
describe "derived settings" do
|
@@ -72,8 +73,7 @@ describe VagrantPlugins::DSC::Config do
|
|
72
73
|
subject.finalize!
|
73
74
|
subject.validate(machine)
|
74
75
|
|
75
|
-
|
76
|
-
expect(subject.expanded_configuration_file.to_s).to eq("#{basePath}/manifests/MyWebsite.ps1")
|
76
|
+
expect(subject.expanded_configuration_file.to_s).to eq("#{subject.temp_dir}/manifests/MyWebsite.ps1")
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -119,9 +119,30 @@ describe VagrantPlugins::DSC::Config do
|
|
119
119
|
|
120
120
|
it "should be invalid if 'configuration_file' is not a real file" do
|
121
121
|
subject.manifests_path = "/"
|
122
|
-
subject.configuration_file = "notexist.
|
122
|
+
subject.configuration_file = "notexist.ps1"
|
123
123
|
assert_invalid
|
124
|
-
assert_error("\"Path to DSC Manifest does not exist: /notexist.
|
124
|
+
assert_error("\"Path to DSC Manifest does not exist: /notexist.ps1\"")
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should be invalid if 'configuration_data_file' is not a real file" do
|
128
|
+
subject.manifests_path = "/"
|
129
|
+
subject.configuration_data_file = "/oeu/aoeu/notexist.psd1"
|
130
|
+
assert_invalid
|
131
|
+
assert_error("\"Path to DSC Configuration Data file does not exist: /oeu/aoeu/notexist.psd1\"")
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should detect the fully qualified path to the configuration data file automatically" do
|
135
|
+
env = double("environment", root_path: "")
|
136
|
+
config = double("config")
|
137
|
+
machine.stub(config: config, env: env)
|
138
|
+
allow(machine).to receive(:root_path).and_return(".")
|
139
|
+
|
140
|
+
subject.configuration_data_file = "manifests/foo.psd1"
|
141
|
+
|
142
|
+
subject.finalize!
|
143
|
+
subject.validate(machine)
|
144
|
+
|
145
|
+
expect(subject.expanded_configuration_data_file.to_s).to eq("#{subject.temp_dir}/manifests/foo.psd1")
|
125
146
|
end
|
126
147
|
|
127
148
|
it "should be invalid if 'module_path' is not a real directory" do
|
@@ -6,17 +6,18 @@ require 'rspec/its'
|
|
6
6
|
describe VagrantPlugins::DSC::Provisioner do
|
7
7
|
include_context "unit"
|
8
8
|
|
9
|
-
let(:root_path)
|
10
|
-
let(:ui)
|
11
|
-
let(:machine)
|
12
|
-
let(:env)
|
13
|
-
let(:vm)
|
14
|
-
let(:communicator)
|
15
|
-
let(:guest)
|
16
|
-
let(:configuration_file)
|
17
|
-
let(:
|
18
|
-
let(:
|
19
|
-
|
9
|
+
let(:root_path) { (Pathname.new(Dir.mktmpdir)).to_s }
|
10
|
+
let(:ui) { Vagrant::UI::Silent.new }
|
11
|
+
let(:machine) { double("machine", ui: ui) }
|
12
|
+
let(:env) { double("environment", root_path: root_path, ui: ui) }
|
13
|
+
let(:vm) { double ("vm") }
|
14
|
+
let(:communicator) { double ("communicator") }
|
15
|
+
let(:guest) { double ("guest") }
|
16
|
+
let(:configuration_file) { "manifests/MyWebsite.ps1" }
|
17
|
+
let(:configuration_data_file) { "manifests/MyConfig.psd1" }
|
18
|
+
let(:module_path) { ["foo/modules", "foo/modules2"] }
|
19
|
+
let(:root_config) { VagrantPlugins::DSC::Config.new }
|
20
|
+
subject { described_class.new machine, root_config }
|
20
21
|
|
21
22
|
describe "configure" do
|
22
23
|
before do
|
@@ -223,7 +224,7 @@ describe VagrantPlugins::DSC::Provisioner do
|
|
223
224
|
|
224
225
|
it "should raise an error if Powershell version is invalid" do
|
225
226
|
|
226
|
-
end
|
227
|
+
end
|
227
228
|
end
|
228
229
|
|
229
230
|
describe "DSC runner script" do
|
@@ -244,7 +245,7 @@ describe VagrantPlugins::DSC::Provisioner do
|
|
244
245
|
|
245
246
|
end
|
246
247
|
|
247
|
-
context "with default parameters" do
|
248
|
+
context "with default parameters" do
|
248
249
|
it "should generate a valid powershell command" do
|
249
250
|
script = subject.generate_dsc_runner_script
|
250
251
|
expect_script = "#
|
@@ -276,6 +277,7 @@ $response = MyWebsite -OutputPath $StagingPath 4>&1 5>&1 | Out-String
|
|
276
277
|
|
277
278
|
# Start a DSC Configuration run
|
278
279
|
$response += Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath 4>&1 5>&1 | Out-String
|
280
|
+
del $StagingPath\\*.mof
|
279
281
|
$response"
|
280
282
|
|
281
283
|
expect(script).to eq(expect_script)
|
@@ -317,6 +319,7 @@ $response = MyWebsite -OutputPath $StagingPath 4>&1 5>&1 | Out-String
|
|
317
319
|
|
318
320
|
# Start a DSC Configuration run
|
319
321
|
$response += Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath 4>&1 5>&1 | Out-String
|
322
|
+
del $StagingPath\\*.mof
|
320
323
|
$response"
|
321
324
|
|
322
325
|
expect(script).to eq(expect_script)
|
@@ -357,6 +360,7 @@ $response = MyWebsite -OutputPath $StagingPath -Foo \"bar\" -ComputerName \"catz
|
|
357
360
|
|
358
361
|
# Start a DSC Configuration run
|
359
362
|
$response += Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath 4>&1 5>&1 | Out-String
|
363
|
+
del $StagingPath\\*.mof
|
360
364
|
$response"
|
361
365
|
|
362
366
|
expect(script).to eq(expect_script)
|
@@ -395,6 +399,7 @@ $response = MyWebsite -OutputPath $StagingPath -FooFlag -BarFlag -FooParam \"Foo
|
|
395
399
|
|
396
400
|
# Start a DSC Configuration run
|
397
401
|
$response += Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath 4>&1 5>&1 | Out-String
|
402
|
+
del $StagingPath\\*.mof
|
398
403
|
$response"
|
399
404
|
|
400
405
|
expect(script).to eq(expect_script)
|
@@ -431,11 +436,70 @@ $StagingPath = \"staging\"
|
|
431
436
|
|
432
437
|
# Start a DSC Configuration run
|
433
438
|
$response += Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath 4>&1 5>&1 | Out-String
|
439
|
+
del $StagingPath\\*.mof
|
440
|
+
$response"
|
441
|
+
|
442
|
+
expect(script).to eq(expect_script)
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
context "with -ConfigurationData" do
|
447
|
+
before do
|
448
|
+
# Prevent counters messing with output in tests
|
449
|
+
Vagrant::Util::Counter.class_eval do
|
450
|
+
def get_and_update_counter(name=nil) 1 end
|
451
|
+
end
|
452
|
+
|
453
|
+
allow(machine).to receive(:root_config).and_return(root_config)
|
454
|
+
root_config.configuration_file = configuration_file
|
455
|
+
root_config.configuration_data_file = configuration_data_file
|
456
|
+
machine.stub(config: root_config, env: env)
|
457
|
+
root_config.module_path = module_path
|
458
|
+
root_config.configuration_file = configuration_file
|
459
|
+
root_config.finalize!
|
460
|
+
root_config.validate(machine)
|
461
|
+
subject.configure(root_config)
|
462
|
+
|
463
|
+
end
|
464
|
+
|
465
|
+
it "should pass in the location of" do
|
466
|
+
script = subject.generate_dsc_runner_script
|
467
|
+
expect_script = "#
|
468
|
+
# DSC Runner.
|
469
|
+
#
|
470
|
+
# Bootstraps the DSC environment, sets up configuration data
|
471
|
+
# and runs the DSC Configuration.
|
472
|
+
#
|
473
|
+
#
|
474
|
+
|
475
|
+
# Set the local PowerShell Module environment path
|
476
|
+
$absoluteModulePaths = [string]::Join(\";\", (\"/tmp/vagrant-dsc-1/modules-0;/tmp/vagrant-dsc-1/modules-1\".Split(\";\") | ForEach-Object { $_ | Resolve-Path }))
|
477
|
+
|
478
|
+
echo \"Adding to path: $absoluteModulePaths\"
|
479
|
+
$env:PSModulePath=\"$absoluteModulePaths;${env:PSModulePath}\"
|
480
|
+
(\"/tmp/vagrant-dsc-1/modules-0;/tmp/vagrant-dsc-1/modules-1\".Split(\";\") | ForEach-Object { gci -Recurse $_ | ForEach-Object { Unblock-File $_.FullName} })
|
481
|
+
|
482
|
+
$script = $(Join-Path \"/tmp/vagrant-dsc-1\" \"manifests/MyWebsite.ps1\" -Resolve)
|
483
|
+
echo \"PSModulePath Configured: ${env:PSModulePath}\"
|
484
|
+
echo \"Running Configuration file: ${script}\"
|
485
|
+
|
486
|
+
# Generate the MOF file, only if a MOF path not already provided.
|
487
|
+
# Import the Manifest
|
488
|
+
. $script
|
489
|
+
|
490
|
+
cd \"/tmp/vagrant-dsc-1\"
|
491
|
+
$StagingPath = $(Join-Path \"/tmp/vagrant-dsc-1\" \"staging\")
|
492
|
+
$response = MyWebsite -OutputPath $StagingPath -ConfigurationData \"/tmp/vagrant-dsc-1/manifests/MyConfig.psd1\" 4>&1 5>&1 | Out-String
|
493
|
+
|
494
|
+
# Start a DSC Configuration run
|
495
|
+
$response += Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath 4>&1 5>&1 | Out-String
|
496
|
+
del $StagingPath\\*.mof
|
434
497
|
$response"
|
435
498
|
|
436
499
|
expect(script).to eq(expect_script)
|
437
500
|
end
|
438
501
|
end
|
502
|
+
|
439
503
|
end
|
440
504
|
|
441
505
|
describe "write DSC Runner script" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-dsc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Fellows
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- README.md
|
166
166
|
- Rakefile
|
167
167
|
- development/Vagrantfile
|
168
|
+
- development/manifests/MyConfig.psd1
|
168
169
|
- development/manifests/MyWebsite.ps1
|
169
170
|
- development/modules/MyWebapp/DSCResources/SimpleWebsite/SimpleWebsite.psd1
|
170
171
|
- development/modules/MyWebapp/DSCResources/SimpleWebsite/SimpleWebsite.schema.psm1
|