vagrant-windows-sysprep 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vagrant-windows-sysprep.rb +31 -10
- data/lib/vagrant-windows-sysprep/{show-sid.ps1 → info.ps1} +2 -1
- data/lib/vagrant-windows-sysprep/sysprep.ps1 +41 -0
- data/lib/vagrant-windows-sysprep/{autounattend.xml → unattend.xml} +9 -0
- data/lib/vagrant-windows-sysprep/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c54e69feb971b2d5962fa047273c8e9f2e14c6046127f785cd76459d8436126c
|
4
|
+
data.tar.gz: d04250e3e6792d9966469a8ec911ab70825b234ad83fbcc7b9511838b398dc07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 668461a1986b312481767ec3dd107fc13e94ad8fb4c03a98d7a1ce8bae0ae5c806a984eec9165df6d407aa8c02eb82f8efec58c0192144c828516972a1600652
|
7
|
+
data.tar.gz: '08d1f86777cd13c21133ec41b8d3497dc40c2dee54ef08e33c68f5de158a1fd895f4785434b3bf8fd1692b00af805d297047945c851d7f7f7bd595f854b398ef'
|
@@ -33,20 +33,27 @@ module VagrantPlugins
|
|
33
33
|
ps = 'PowerShell -ExecutionPolicy Bypass -OutputFormat Text'
|
34
34
|
|
35
35
|
original_machine_sid = ''
|
36
|
-
|
36
|
+
original_machine_computer_name = ''
|
37
|
+
info_remote_path = "C:/Windows/Temp/vagrant-windows-sysprep-info.ps1"
|
37
38
|
@machine.communicate.upload(
|
38
|
-
File.join(File.dirname(__FILE__), "vagrant-windows-sysprep", "
|
39
|
-
|
40
|
-
|
41
|
-
@machine.communicate.sudo(
|
39
|
+
File.join(File.dirname(__FILE__), "vagrant-windows-sysprep", "info.ps1"),
|
40
|
+
info_remote_path)
|
41
|
+
info_command = "#{ps} -File #{info_remote_path}"
|
42
|
+
@machine.communicate.sudo(info_command, {elevated: true, interactive: false}) do |type, data|
|
42
43
|
original_machine_sid = $1.strip if data =~ /This Machine SID is (.+)/
|
44
|
+
original_machine_computer_name = $1.strip if data =~ /This Machine ComputerName is (.+)/
|
43
45
|
end
|
44
46
|
|
45
|
-
|
47
|
+
unattend_remote_path = "C:/Windows/Temp/vagrant-windows-sysprep-unattend.xml"
|
46
48
|
@machine.communicate.upload(
|
47
|
-
File.join(File.dirname(__FILE__), "vagrant-windows-sysprep", "
|
48
|
-
|
49
|
-
|
49
|
+
File.join(File.dirname(__FILE__), "vagrant-windows-sysprep", "unattend.xml"),
|
50
|
+
unattend_remote_path)
|
51
|
+
|
52
|
+
sysprep_remote_path = "C:/Windows/Temp/vagrant-windows-sysprep.ps1"
|
53
|
+
@machine.communicate.upload(
|
54
|
+
File.join(File.dirname(__FILE__), "vagrant-windows-sysprep", "sysprep.ps1"),
|
55
|
+
sysprep_remote_path)
|
56
|
+
sysprep_command = "#{ps} -File #{sysprep_remote_path}"
|
50
57
|
begin
|
51
58
|
@machine.communicate.sudo(sysprep_command, {elevated: true, interactive: false}) do |type, data|
|
52
59
|
handle_comm(type, data)
|
@@ -67,9 +74,23 @@ module VagrantPlugins
|
|
67
74
|
@machine.action(:up, options)
|
68
75
|
|
69
76
|
machine_sid = ''
|
70
|
-
|
77
|
+
machine_computer_name = ''
|
78
|
+
@machine.communicate.sudo(info_command, {elevated: true, interactive: false}) do |type, data|
|
71
79
|
machine_sid = $1.strip if data =~ /This Machine SID is (.+)/
|
80
|
+
machine_computer_name = $1.strip if data =~ /This Machine ComputerName is (.+)/
|
72
81
|
end
|
82
|
+
|
83
|
+
# NB there's a bug somewhere in windows sysprep machinery that prevents it from setting the
|
84
|
+
# ComputerName when the name doesn't really change (like when you use config.vm.hostname),
|
85
|
+
# it will instead set the ComputerName to something like WIN-0F47SUATAF5.
|
86
|
+
# this workaround will compensate for that by renaming the computer.
|
87
|
+
# NB sysprep works in Windows 2016 14393.2906.
|
88
|
+
# NB sysprep fails in Windows 2019 17763.437.
|
89
|
+
if machine_computer_name != original_machine_computer_name
|
90
|
+
@machine.ui.info "Sysprep did not correctly set ComputerName... renaming it from #{machine_computer_name} to #{original_machine_computer_name}..."
|
91
|
+
@machine.guest.capability(:change_host_name, original_machine_computer_name)
|
92
|
+
end
|
93
|
+
|
73
94
|
@machine.ui.success "The Machine SID was changed from #{original_machine_sid} to #{machine_sid}"
|
74
95
|
end
|
75
96
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
param(
|
2
|
+
[string]$ComputerName = $null
|
3
|
+
)
|
4
|
+
|
5
|
+
Set-StrictMode -Version Latest
|
6
|
+
$ErrorActionPreference = 'Stop'
|
7
|
+
$ProgressPreference = 'SilentlyContinue'
|
8
|
+
trap {
|
9
|
+
Write-Output "ERROR: $_"
|
10
|
+
Write-Output (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
|
11
|
+
Write-Output (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$','ERROR EXCEPTION: $1')
|
12
|
+
Exit 1
|
13
|
+
}
|
14
|
+
|
15
|
+
if (!$ComputerName) {
|
16
|
+
$ComputerName = $env:COMPUTERNAME
|
17
|
+
}
|
18
|
+
|
19
|
+
$unattendPath = "$PSScriptRoot\vagrant-windows-sysprep-unattend.xml"
|
20
|
+
|
21
|
+
# NB there's a bug somewhere in windows sysprep machinery that prevents it from setting the
|
22
|
+
# ComputerName when the name doesn't really change (like when you use config.vm.hostname),
|
23
|
+
# it will instead set the ComputerName to something like WIN-0F47SUATAF5.
|
24
|
+
# so this configuration will not really work... but its here to see when they fix this problem.
|
25
|
+
Write-Host "Configuring sysprep to set ComputerName to $ComputerName..."
|
26
|
+
Set-Content `
|
27
|
+
-Encoding UTF8 `
|
28
|
+
-Path $unattendPath `
|
29
|
+
-Value (
|
30
|
+
(Get-Content -Raw $unattendPath) `
|
31
|
+
-replace '@@COMPUTERNAME@@',$ComputerName
|
32
|
+
)
|
33
|
+
|
34
|
+
Write-Host 'Syspreping...'
|
35
|
+
C:/Windows/System32/Sysprep/sysprep.exe `
|
36
|
+
/generalize `
|
37
|
+
/oobe `
|
38
|
+
/quiet `
|
39
|
+
/shutdown `
|
40
|
+
"/unattend:$unattendPath" `
|
41
|
+
| Out-String -Stream
|
@@ -1,4 +1,8 @@
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!--
|
3
|
+
sysprep copies this file to C:\Windows\Panther\unattend.xml
|
4
|
+
the logs are stored at C:\Windows\Panther\setupact.log
|
5
|
+
-->
|
2
6
|
<unattend xmlns="urn:schemas-microsoft-com:unattend">
|
3
7
|
<settings pass="generalize">
|
4
8
|
<component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
@@ -9,6 +13,11 @@
|
|
9
13
|
<DoNotCleanUpNonPresentDevices>true</DoNotCleanUpNonPresentDevices>
|
10
14
|
</component>
|
11
15
|
</settings>
|
16
|
+
<settings pass="specialize">
|
17
|
+
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
18
|
+
<ComputerName>@@COMPUTERNAME@@</ComputerName>
|
19
|
+
</component>
|
20
|
+
</settings>
|
12
21
|
<settings pass="oobeSystem">
|
13
22
|
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
14
23
|
<InputLocale>en-US</InputLocale>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-windows-sysprep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rui Lopes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -31,8 +31,9 @@ extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
33
|
- lib/vagrant-windows-sysprep.rb
|
34
|
-
- lib/vagrant-windows-sysprep/
|
35
|
-
- lib/vagrant-windows-sysprep/
|
34
|
+
- lib/vagrant-windows-sysprep/info.ps1
|
35
|
+
- lib/vagrant-windows-sysprep/sysprep.ps1
|
36
|
+
- lib/vagrant-windows-sysprep/unattend.xml
|
36
37
|
- lib/vagrant-windows-sysprep/version.rb
|
37
38
|
homepage: https://github.com/rgl/vagrant-windows-sysprep
|
38
39
|
licenses:
|