Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
packer-windows
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bob Tanner
packer-windows
Commits
95c50cfc
Unverified
Commit
95c50cfc
authored
Nov 25, 2017
by
Stefan Scherer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add two nested builder vm's
parent
3ff7bee3
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
162 additions
and
104 deletions
+162
-104
hyperv/README.md
hyperv/README.md
+0
-49
hyperv/scripts/install-docker-machine.ps1
hyperv/scripts/install-docker-machine.ps1
+0
-1
hyperv/scripts/install-docker.ps1
hyperv/scripts/install-docker.ps1
+0
-2
hyperv/scripts/install-packer.ps1
hyperv/scripts/install-packer.ps1
+0
-1
hyperv/scripts/install-vagrant.ps1
hyperv/scripts/install-vagrant.ps1
+0
-1
nested/.gitignore
nested/.gitignore
+0
-0
nested/README.md
nested/README.md
+82
-0
nested/Vagrantfile
nested/Vagrantfile
+56
-50
nested/scripts/copy-templates.ps1
nested/scripts/copy-templates.ps1
+10
-0
nested/scripts/install-hyperv.ps1
nested/scripts/install-hyperv.ps1
+4
-0
nested/scripts/install-tools.ps1
nested/scripts/install-tools.ps1
+9
-0
nested/scripts/install-virtualbox.ps1
nested/scripts/install-virtualbox.ps1
+1
-0
nested/terraform/.gitignore
nested/terraform/.gitignore
+0
-0
nested/terraform/FirstLogonCommands.xml
nested/terraform/FirstLogonCommands.xml
+0
-0
nested/terraform/README.md
nested/terraform/README.md
+0
-0
nested/terraform/init.tf
nested/terraform/init.tf
+0
-0
nested/terraform/provision.ps1
nested/terraform/provision.ps1
+0
-0
nested/terraform/variables.tf
nested/terraform/variables.tf
+0
-0
nested/terraform/windows.tf
nested/terraform/windows.tf
+0
-0
No files found.
hyperv/README.md
deleted
100644 → 0
View file @
3ff7bee3
# hyperv
This Vagrant environment can be used to spin up a Windows 10 VM to create the 2016 Hyper-V Vagrant boxes.
The VM needs about 6GByte RAM and 100 GByte disk.
Tested with VMware Fusion 8 and VMware Workstation 12.
## On your OSX/Windows host
### Build the Windows 10 VMware base box
Build the Windows 10 base box for VMware Fusion/Workstation with 100GByte disk size.
```
bash
cd
..
packer build
--only
=
vmware-iso
-var
disk_size
=
102400 windows_10.json
vagrant box add windows_10 windows_10_vmware.box
```
### Build the Windows 10 Hyper-V environment
Now build the Vagrant environment with Hyper-V and packer in a Windows 10 VM.
```
bash
cd
hyperv
vagrant up
--provider
vmware_fusion
```
## In the Windows 10 VM
### Build the Windows Server 2016 Hyper-V base box
Now inside the Windows 10 VM create a Hyper-V external switch and then run
packer with this command
```
powershell
cd
C:\vagrant
packer
build
--only
=
hyperv-iso
-var
'hyperv_switchname=Wifi'
windows_2016_docker.iso
```
You probably have to copy the C:
\v
agrant folder into the VM as packer would work
on a shared folder of the host.
### Run the Hyper-V VM in Windows 10
```
powershell
vagrant
box
add
windows_2016_docker
windows_2016_docker_hyperv.box
cd
C:\Users\vagrant
git
clone
https://github.com/StefanScherer/docker-windows-box
cd
docker-windows-box
vagrant
up
```
hyperv/scripts/install-docker-machine.ps1
deleted
100644 → 0
View file @
3ff7bee3
choco
install
-y
docker-machine
hyperv/scripts/install-docker.ps1
deleted
100644 → 0
View file @
3ff7bee3
Write-Host
Installing
Docker
client
choco
install
-y
docker
hyperv/scripts/install-packer.ps1
deleted
100644 → 0
View file @
3ff7bee3
choco
install
-y
packer
hyperv/scripts/install-vagrant.ps1
deleted
100644 → 0
View file @
3ff7bee3
choco
install
-y
vagrant
-version
1.9.1
hyperv
/.gitignore
→
nested
/.gitignore
View file @
95c50cfc
File moved
nested/README.md
0 → 100644
View file @
95c50cfc
# nested
With this Vagrant environment you can build for other hypervisors in a nested
VMware VM. Or you can have a look at the provision scripts how to install
all tools needed on bare metal.
## Preparation
On your host with VMware.
### Build the Windows 10 VMware base box
Build the Windows 10 base box for VMware Fusion/Workstation with 100GByte disk size.
```
bash
cd
..
packer build
--only
=
vmware-iso
-var
disk_size
=
102400 windows_10.json
vagrant box add windows_10 windows_10_vmware.box
```
## Hyper-V
Now build the Vagrant environment with Hyper-V and packer in a Windows 10 VM.
```
bash
cd
nested
vagrant up hyperv
```
### Build a Hyper-V Vagrant box
In the nested Windows 10 VM with Hyper-V first create an external virtual
switch in Hyper-V Manager. Then you can run Packer builds.
```
powershell
cd
C:\Users\vagrant\packer-windows
packer
build
--only
=
hyperv-iso
--var
hyperv_switchname
=
ext
windows_2016_docker.iso
```
You can copy the boxes produced back to C:
\v
agrant folder
that is a shared folder of the host.
### Run the Hyper-V VM in Windows 10
```
powershell
vagrant
box
add
windows_2016_docker
windows_2016_docker_hyperv.box
cd
C:\Users\vagrant
git
clone
https://github.com/StefanScherer/docker-windows-box
cd
docker-windows-box
vagrant
up
```
## VirtualBox
Now build the Vagrant environment with VirtualBox and packer in a Windows 10 VM.
```
bash
cd
nested
vagrant up virtualbox
```
### Build a VirtualBox Vagrant box
In the nested Windows 10 VM with VirtualBox installed you can run Packer builds.
```
powershell
cd
C:\Users\vagrant\packer-windows
packer
build
--only
=
virtualbox-iso
windows_2016_docker.iso
```
You can copy the boxes produced back to C:
\v
agrant folder
that is a shared folder of the host.
### Run the VirtualBox VM in Windows 10
```
powershell
vagrant
box
add
windows_2016_docker
windows_2016_docker_virtualbox.box
cd
C:\Users\vagrant
git
clone
https://github.com/StefanScherer/docker-windows-box
cd
docker-windows-box
vagrant
up
```
hyperv
/Vagrantfile
→
nested
/Vagrantfile
View file @
95c50cfc
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION
=
"2"
Vagrant
.
configure
(
VAGRANTFILE_API_VERSION
)
do
|
config
|
config
.
vm
.
box
=
"windows_10"
config
.
vm
.
network
:forwarded_port
,
guest:
5985
,
host:
5985
,
id:
"winrm"
,
auto_correct:
true
config
.
vm
.
communicator
=
"winrm"
config
.
winrm
.
username
=
"vagrant"
config
.
winrm
.
password
=
"vagrant"
config
.
vm
.
guest
=
:windows
config
.
windows
.
halt_timeout
=
15
config
.
vm
.
synced_folder
"."
,
"/vagrant"
,
disabled:
true
config
.
vm
.
synced_folder
".."
,
"/vagrant"
config
.
vm
.
provision
"shell"
,
path:
"scripts/install-chocolatey.ps1"
,
privileged:
false
config
.
vm
.
provision
"shell"
,
path:
"scripts/install-hyperv.ps1"
,
privileged:
false
config
.
vm
.
provision
"reload"
config
.
vm
.
provision
"shell"
,
path:
"scripts/install-packer.ps1"
,
privileged:
false
config
.
vm
.
provision
"shell"
,
path:
"scripts/install-vagrant.ps1"
,
privileged:
false
config
.
vm
.
provision
"shell"
,
path:
"scripts/install-docker.ps1"
,
privileged:
false
config
.
vm
.
provision
"shell"
,
path:
"scripts/install-docker-machine.ps1"
,
privileged:
false
[
"vmware_fusion"
,
"vmware_workstation"
].
each
do
|
provider
|
config
.
vm
.
provider
provider
do
|
v
,
override
|
v
.
gui
=
true
v
.
enable_vmrun_ip_lookup
=
false
v
.
vmx
[
"memsize"
]
=
"6048"
v
.
vmx
[
"numvcpus"
]
=
"2"
v
.
vmx
[
"vhv.enable"
]
=
"TRUE"
end
end
config
.
vm
.
provider
"vmware_fusion"
do
|
v
|
v
.
vmx
[
"gui.fitguestusingnativedisplayresolution"
]
=
"TRUE"
v
.
vmx
[
"mks.enable3d"
]
=
"TRUE"
v
.
vmx
[
"mks.forceDiscreteGPU"
]
=
"TRUE"
v
.
vmx
[
"gui.fullscreenatpoweron"
]
=
"TRUE"
v
.
vmx
[
"gui.viewmodeatpoweron"
]
=
"fullscreen"
v
.
vmx
[
"gui.lastPoweredViewMode"
]
=
"fullscreen"
v
.
vmx
[
"sound.startconnected"
]
=
"TRUE"
v
.
vmx
[
"sound.present"
]
=
"TRUE"
v
.
vmx
[
"sound.autodetect"
]
=
"TRUE"
end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION
=
"2"
Vagrant
.
configure
(
VAGRANTFILE_API_VERSION
)
do
|
config
|
config
.
vm
.
box
=
"windows_10"
config
.
vm
.
network
:forwarded_port
,
guest:
5985
,
host:
5985
,
id:
"winrm"
,
auto_correct:
true
config
.
vm
.
communicator
=
"winrm"
config
.
winrm
.
username
=
"vagrant"
config
.
winrm
.
password
=
"vagrant"
config
.
vm
.
guest
=
:windows
config
.
windows
.
halt_timeout
=
15
config
.
vm
.
synced_folder
"."
,
"/vagrant"
,
disabled:
true
config
.
vm
.
synced_folder
".."
,
"/vagrant"
config
.
vm
.
define
"hyperv"
do
|
cfg
|
config
.
vm
.
provision
"shell"
,
path:
"scripts/install-hyperv.ps1"
,
privileged:
false
config
.
vm
.
provision
"reload"
config
.
vm
.
provision
"shell"
,
path:
"scripts/copy-templates.ps1"
,
privileged:
false
config
.
vm
.
provision
"shell"
,
path:
"scripts/install-tools.ps1"
,
privileged:
false
end
config
.
vm
.
define
"virtualbox"
do
|
cfg
|
config
.
vm
.
provision
"shell"
,
path:
"scripts/copy-templates.ps1"
,
privileged:
false
config
.
vm
.
provision
"shell"
,
path:
"scripts/install-tools.ps1"
,
privileged:
false
config
.
vm
.
provision
"shell"
,
path:
"scripts/install-virtualbox.ps1"
,
privileged:
false
config
.
vm
.
provision
"reload"
end
[
"vmware_fusion"
,
"vmware_workstation"
].
each
do
|
provider
|
config
.
vm
.
provider
provider
do
|
v
,
override
|
v
.
gui
=
true
v
.
enable_vmrun_ip_lookup
=
false
v
.
vmx
[
"memsize"
]
=
"6048"
v
.
vmx
[
"numvcpus"
]
=
"2"
v
.
vmx
[
"vhv.enable"
]
=
"TRUE"
end
end
config
.
vm
.
provider
"vmware_fusion"
do
|
v
|
v
.
vmx
[
"gui.fitguestusingnativedisplayresolution"
]
=
"TRUE"
v
.
vmx
[
"mks.enable3d"
]
=
"TRUE"
v
.
vmx
[
"mks.forceDiscreteGPU"
]
=
"TRUE"
v
.
vmx
[
"gui.fullscreenatpoweron"
]
=
"TRUE"
v
.
vmx
[
"gui.viewmodeatpoweron"
]
=
"fullscreen"
v
.
vmx
[
"gui.lastPoweredViewMode"
]
=
"fullscreen"
v
.
vmx
[
"sound.startconnected"
]
=
"TRUE"
v
.
vmx
[
"sound.present"
]
=
"TRUE"
v
.
vmx
[
"sound.autodetect"
]
=
"TRUE"
end
end
nested/scripts/copy-templates.ps1
0 → 100644
View file @
95c50cfc
mkdir
$
env
:
USERPROFILE
\packer-windows
cd
$
env
:
USERPROFILE
\packer-windows
copy
\vagrant\
*.
json
.
copy
\vagrant\vag
*
.
copy
-re
\vagrant\answer_files\
answer_files
copy
-re
\vagrant\floppy\
floppy
copy
-re
\vagrant\scripts\
scripts
if
(
Test-Path
\vagrant\packer_cache\
)
{
copy
-re
\vagrant\packer_cache\
packer_cache
}
hyperv
/scripts/install-hyperv.ps1
→
nested
/scripts/install-hyperv.ps1
View file @
95c50cfc
Enable-WindowsOptionalFeature
-Online
-FeatureName
Microsoft-Hyper-V
-All
-NoRestart
Install-WindowsFeature
Hyper-V-Tools
Install-WindowsFeature
Hyper-V-PowerShell
Enable-WindowsOptionalFeature
-Online
-FeatureName
Microsoft-Hyper-V
-All
-NoRestart
$username
=
$
env
:
USERNAME
net
localgroup
"Hyper-V Administrators"
$username
/add
hyperv/scripts/install-chocolatey
.ps1
→
nested/scripts/install-tools
.ps1
View file @
95c50cfc
# install chocolatey
iex
(
wget
'https://chocolatey.org/install.ps1'
-UseBasicParsing
)
choco
install
-y
packer
choco
install
-y
vagrant
choco
install
-y
docker
choco
install
-y
docker-machine
nested/scripts/install-virtualbox.ps1
0 → 100644
View file @
95c50cfc
choco
install
-y
virtualbox
hyperv
/terraform/.gitignore
→
nested
/terraform/.gitignore
View file @
95c50cfc
File moved
hyperv
/terraform/FirstLogonCommands.xml
→
nested
/terraform/FirstLogonCommands.xml
View file @
95c50cfc
File moved
hyperv
/terraform/README.md
→
nested
/terraform/README.md
View file @
95c50cfc
File moved
hyperv
/terraform/init.tf
→
nested
/terraform/init.tf
View file @
95c50cfc
File moved
hyperv
/terraform/provision.ps1
→
nested
/terraform/provision.ps1
View file @
95c50cfc
File moved
hyperv
/terraform/variables.tf
→
nested
/terraform/variables.tf
View file @
95c50cfc
File moved
hyperv
/terraform/windows.tf
→
nested
/terraform/windows.tf
View file @
95c50cfc
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment