vagrant-dsc 1.0.4 → 1.0.5

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: 407c2cc8f7c8786fe7628c4894ed967be86d05aa
4
- data.tar.gz: 4f093c1e28adb46cdbc804ad8cc4a329d03f9008
3
+ metadata.gz: a27d30fb1437143bb3969c933581d2a78549134e
4
+ data.tar.gz: e45f109d21e48ad8d6226f3fa729b89993fffea1
5
5
  SHA512:
6
- metadata.gz: 568a9dfdb800956ad3724a3a2582a3a7785310142ac139273577cc3643475fbf02d478c13ca7056b9aabffc746a54d04253e33f580327892b50830d4298cd482
7
- data.tar.gz: 7f063bd5ce7baa8b876296306d67da778a9b9597be5a3ccae045a2f4152b6e463e19d9d379b83686dd845daff76118055afc9c4d0c933b90e7293e8bf49f1dbe
6
+ metadata.gz: aaf2163219c6c17f22d78494b28897ac0c203f2e51658ec509abd19556260b6224c49b02dfd71169a6de6424dc7015b03a9c5131280fe5cb788d9c13bc13e348
7
+ data.tar.gz: d05416921b9d639382e006e4bae98bda92c1776ee7a45692257ec120f9b0f2c3a80b0056d9703f74133ee9ae4aa3a63346a90e7d4d2d574951303f2312fbed0e
data/README.md CHANGED
@@ -22,6 +22,7 @@ In your Vagrantfile, add the following plugin and configure to your needs:
22
22
 
23
23
  ```ruby
24
24
  config.vm.provision "dsc" do |dsc|
25
+
25
26
  # The path relative to `dsc.manifests_path` pointing to the Configuration file
26
27
  dsc.configuration_file = "MyWebsite.ps1"
27
28
 
@@ -35,16 +36,22 @@ In your Vagrantfile, add the following plugin and configure to your needs:
35
36
  # To pass in flags, simply set the value to `nil`
36
37
  dsc.configuration_params = {"-MachineName" => "localhost", "-EnableDebug" => nil}
37
38
 
39
+ # A path relative to the Vagrantfile pointing to a Configuration Data file.
40
+ #
41
+ # See https://technet.microsoft.com/en-us/library/dn249925.aspx for details
42
+ # on how to parameterise your Configuration files.
43
+ dsc.configuration_data_file = "manifests/MyConfig.psd1"
44
+
38
45
  # Relative path to a folder containing a pre-generated MOF file.
39
46
  #
40
47
  # Path is relative to the folder containing the Vagrantfile.
41
- #dsc.mof_path = "mof_output"
48
+ dsc.mof_path = "mof_output"
42
49
 
43
50
  # Relative path to the folder containing the root Configuration manifest file.
44
51
  # Defaults to 'manifests'.
45
52
  #
46
53
  # Path is relative to the folder containing the Vagrantfile.
47
- # dsc.manifests_path = "manifests"
54
+ dsc.manifests_path = "manifests"
48
55
 
49
56
  # Set of module paths relative to the Vagrantfile dir.
50
57
  #
@@ -52,17 +59,17 @@ In your Vagrantfile, add the following plugin and configure to your needs:
52
59
  # environment to enable local modules to be addressed.
53
60
  #
54
61
  # @return [Array] Set of relative module paths.
55
- #dsc.module_path = ["manifests", "modules"]
62
+ dsc.module_path = ["manifests", "modules"]
56
63
 
57
64
  # The type of synced folders to use when sharing the data
58
65
  # required for the provisioner to work properly.
59
66
  #
60
67
  # By default this will use the default synced folder type.
61
68
  # For example, you can set this to "nfs" to use NFS synced folders.
62
- #dsc.synced_folder_type = ""
69
+ dsc.synced_folder_type = "nfs"
63
70
 
64
71
  # Temporary working directory on the guest machine.
65
- #dsc.temp_dir = "/tmp/vagrant-dsc"
72
+ dsc.temp_dir = "/tmp/vagrant-dsc"
66
73
  end
67
74
  ```
68
75
  ## Example
@@ -70,6 +77,10 @@ In your Vagrantfile, add the following plugin and configure to your needs:
70
77
  There is a [sample](https://github.com/mefellows/vagrant-dsc/tree/master/development) Vagrant setup used for development of this plugin.
71
78
  This is a great real-life example to get you on your way.
72
79
 
80
+ ## Creating Windows Vagrant boxes
81
+
82
+ Look at some example Packer templates [here](https://github.com/mefellows/packer-windows-templates/).
83
+
73
84
  ## Roadmap
74
85
 
75
86
  * Support DSC Pull Server provisioning
@@ -6,7 +6,7 @@ $shell_script = <<SCRIPT
6
6
  #choco install seek-dsc
7
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
8
  choco install 7zip
9
- 7za.exe x -y C:\\xwebadmin.zip -o'C:\\Program Files\\WindowsPowerShell\\Modules'
9
+ & 'C:\\Program Files\\7-Zip\\7z.exe' x -y C:\\xwebadmin.zip -o'C:\\Program Files\\WindowsPowerShell\\Modules'
10
10
  Get-DSCResource
11
11
  SCRIPT
12
12
 
@@ -19,9 +19,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
19
19
  # please see the online documentation at vagrantup.com.
20
20
 
21
21
  # Every Vagrant virtual environment requires a box to build off of.
22
- # config.vm.box = "mfellows/windows2012r2"
23
- # config.vm.box_version = "1.0.1"
24
- config.vm.box = "windows2012r2"
22
+ config.vm.box = "mfellows/windows2012r2"
23
+ config.vm.box_version = "1.0.1"
25
24
 
26
25
  config.vm.guest = :windows
27
26
  config.vm.communicator = "winrm"
@@ -191,32 +191,28 @@ module VagrantPlugins
191
191
 
192
192
  # Runs the DSC Configuration on the guest machine.
193
193
  def run_dsc_apply
194
- command = ". '#{DSC_GUEST_RUNNER_PATH}'"
195
194
 
196
195
  @machine.ui.info(I18n.t(
197
196
  "vagrant_dsc.running_dsc",
198
197
  manifest: config.configuration_file))
199
198
 
200
- opts = {
201
- elevated: true,
202
- error_key: :ssh_bad_exit_status_muted,
203
- good_exit: 0,
204
- shell: :powershell
205
- }
206
-
207
- @machine.communicate.sudo(command, opts) do |type, data|
199
+ # A bit of an ugly dance, but this is how we get neat, colourised output and exit codes from a Powershell run
200
+ last_type = nil
201
+ new_line = ""
202
+ error = false
203
+ machine.communicate.shell.powershell("powershell -ExecutionPolicy Bypass -OutputFormat Text -file #{DSC_GUEST_RUNNER_PATH}") do |type, data|
208
204
  if !data.chomp.empty?
205
+ error = true if type == :stderr
209
206
  if [:stderr, :stdout].include?(type)
210
- # Output the data with the proper color based on the stream.
211
- # TODO: Seems the WinRM communicator or a bug in my powershell code
212
- # precludes from errors coming back in the :stderr stream
213
207
  color = type == :stdout ? :green : :red
214
- @machine.ui.info(
215
- data.chomp,
216
- color: color, new_line: false, prefix: false)
208
+ new_line = "\r\n" if last_type != nil and last_type != type
209
+ last_type = type
210
+ @machine.ui.info( new_line + data.chomp, color: color, new_line: false, prefix: false)
217
211
  end
218
212
  end
219
213
  end
214
+
215
+ error == false
220
216
  end
221
217
 
222
218
  # Verify that the shared folders have been properly configured
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Dsc
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
@@ -11,6 +11,7 @@ describe VagrantPlugins::DSC::Provisioner do
11
11
  let(:machine) { double("machine", ui: ui) }
12
12
  let(:env) { double("environment", root_path: root_path, ui: ui) }
13
13
  let(:vm) { double ("vm") }
14
+ let(:shell) { double ("shell") }
14
15
  let(:communicator) { double ("communicator") }
15
16
  let(:guest) { double ("guest") }
16
17
  let(:configuration_file) { "manifests/MyWebsite.ps1" }
@@ -523,21 +524,26 @@ $response"
523
524
 
524
525
  describe "Apply DSC" do
525
526
  it "should invoke the DSC Runner and notify the User of provisioning status" do
526
- expect(ui).to receive(:info).with(any_args).once
527
- expect(ui).to receive(:info).with("provisioned!", {color: :green, new_line: false, prefix: false}).once
527
+ allow(communicator).to receive(:shell).and_return(shell)
528
528
  allow(machine).to receive(:communicate).and_return(communicator)
529
- expect(communicator).to receive(:sudo).with('. ' + "'c:/tmp/vagrant-dsc-runner.ps1'",{:elevated=>true, :error_key=>:ssh_bad_exit_status_muted, :good_exit=>0, :shell=>:powershell}).and_yield(:stdout, "provisioned!")
529
+ expect(shell).to receive(:powershell).with("powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:/tmp/vagrant-dsc-runner.ps1").and_yield(:stdout, "provisioned!")
530
+ root_config.configuration_file = configuration_file
531
+ expect(ui).to receive(:info).with("\"Running DSC Provisioner with manifests/MyWebsite.ps1...\"")
532
+ expect(ui).to receive(:info).with("provisioned!", {color: :green, new_line: false, prefix: false}).once
530
533
 
531
534
  subject.run_dsc_apply
532
535
  end
533
536
 
534
537
  it "should show error output in red" do
535
- expect(ui).to receive(:info).with(any_args).once
536
- expect(ui).to receive(:info).with("provisioned!", {color: :red, new_line: false, prefix: false}).once
537
538
  allow(machine).to receive(:communicate).and_return(communicator)
538
- expect(communicator).to receive(:sudo).with('. ' + "'c:/tmp/vagrant-dsc-runner.ps1'",{:elevated=>true, :error_key=>:ssh_bad_exit_status_muted, :good_exit=>0, :shell=>:powershell}).and_yield(:stderr, "provisioned!")
539
+ allow(communicator).to receive(:shell).and_return(shell)
540
+
541
+ root_config.configuration_file = configuration_file
542
+ expect(ui).to receive(:info).with("\"Running DSC Provisioner with manifests/MyWebsite.ps1...\"")
543
+ expect(ui).to receive(:info).with("not provisioned!", {color: :red, new_line: false, prefix: false}).once
544
+ expect(shell).to receive(:powershell).with("powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:/tmp/vagrant-dsc-runner.ps1").and_yield(:stderr, "not provisioned!")
539
545
 
540
546
  subject.run_dsc_apply
541
547
  end
542
548
  end
543
- end
549
+ end
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
4
+ version: 1.0.5
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-29 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  version: '0'
207
207
  requirements: []
208
208
  rubyforge_project:
209
- rubygems_version: 2.4.1
209
+ rubygems_version: 2.0.14
210
210
  signing_key:
211
211
  specification_version: 4
212
212
  summary: DSC Provisioner for Vagrant