Skip to content

Commit

Permalink
Ensure Chef client files are cleaned up after uninstall #11 #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusztáv Varga committed Sep 25, 2016
1 parent 889d0c6 commit 50ef089
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 35 deletions.
3 changes: 1 addition & 2 deletions windows/chef/cookbooks/packer_windows/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
default['packer_windows'] = {
'virtualbox_guest' => {
'version' => '5.1.2',
'source_base_url' => 'http://download.virtualbox.org/virtualbox'
'version' => '5.1.2'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
action :create
end

file_name = "VBoxGuestAdditions_#{version}.iso"
file_path = "#{directory_path}/#{file_name}"
source_url = "#{node['packer_windows']['virtualbox_guest']['source_base_url']}/#{version}/#{file_name}"
iso_file_name = "VBoxGuestAdditions_#{version}.iso"
iso_file_path = "#{directory_path}/#{iso_file_name}"
iso_file_source_url = "http://download.virtualbox.org/virtualbox/#{version}/#{iso_file_name}"

remote_file file_path do
source source_url
remote_file iso_file_path do
source iso_file_source_url
action :create
end

packer_windows_iso file_path do
packer_windows_iso iso_file_path do
drive_letter 'I'
action :mount
end
Expand All @@ -30,7 +30,7 @@
action :run
end

packer_windows_iso file_path do
packer_windows_iso iso_file_path do
action :dismount
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
echo "Uninstalling Chef Client"
@echo off

timeout /t 10 /nobreak
cuninst -y chef-client
timeout /t 10 /nobreak
rmdir /s /q C:\opscode

echo "Disabling WinRM"
netsh advfirewall firewall set rule name="WinRM-HTTP" new action=block

echo "Executing Sysprep"
copy A:\Autounattend.sysprep.xml C:\Windows
mkdir C:\Windows\Setup\Scripts
copy A:\Autounattend.sysprep.bat C:\Windows\Setup\Scripts\SetupComplete.cmd

C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /quiet /shutdown /unattend:C:\Windows\Autounattend.sysprep.xml
A:\sysprep.bat
2 changes: 1 addition & 1 deletion windows10ee/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This folder contains the [Packer] template to build a [Vagrant] base box for Windows 10.

This box includes the following components:
This box contains the following components:

* Windows 10 Enterprise Evaluation
* VirtualBox Guest Additions
Expand Down
4 changes: 2 additions & 2 deletions windows10ee/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"disk_size": "31744",
"boot_wait": "1m",
"guest_additions_mode": "disable",
"guest_additions_mode": "disable",
"floppy_files": [
"../windows/virtualbox-iso",
"virtualbox-iso"
Expand Down Expand Up @@ -68,7 +68,7 @@
"post-processors": [
{
"type": "vagrant",
"output": "gusztavvargadr--windows10ee--0.1.0--{{.Provider}}.box",
"output": "gusztavvargadr--windows10ee--0.1.1--{{.Provider}}.box",
"vagrantfile_template": "../windows/vagrant/Vagrantfile"
}
]
Expand Down
16 changes: 0 additions & 16 deletions windows10ee/virtualbox-iso/shutdown.bat

This file was deleted.

5 changes: 5 additions & 0 deletions windows10ee/virtualbox-iso/sysprep.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /quiet /quit /unattend:C:\Windows\Autounattend.sysprep.xml

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OOBE" /v UnattendCreatedUser /d 1 /t REG_DWORD /f /reg:64

shutdown /s /t 1
2 changes: 1 addition & 1 deletion windows2012r2se/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This folder contains the [Packer] template to build a [Vagrant] base box for Windows Server 2012 R2.

This box includes the following components:
This box contains the following components:

* Windows Server 2012 R2 Standard Evaluation
* VirtualBox Guest Additions
Expand Down
4 changes: 2 additions & 2 deletions windows2012r2se/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"disk_size": "31744",
"boot_wait": "1m",
"guest_additions_mode": "disable",
"guest_additions_mode": "disable",
"floppy_files": [
"../windows/virtualbox-iso",
"virtualbox-iso"
Expand Down Expand Up @@ -68,7 +68,7 @@
"post-processors": [
{
"type": "vagrant",
"output": "gusztavvargadr--windows2012r2se--0.1.0--{{.Provider}}.box",
"output": "gusztavvargadr--windows2012r2se--0.1.1--{{.Provider}}.box",
"vagrantfile_template": "../windows/vagrant/Vagrantfile"
}
]
Expand Down
1 change: 1 addition & 0 deletions windows2012r2se/virtualbox-iso/sysprep.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /quiet /shutdown /unattend:C:\Windows\Autounattend.sysprep.xml

0 comments on commit 50ef089

Please sign in to comment.