Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Bob Tanner
packer-windows
Commits
95c50cfc
Unverified
Commit
95c50cfc
authored
Nov 25, 2017
by
Stefan Scherer
Browse files
Add two nested builder vm's
parent
3ff7bee3
Changes
19
Show whitespace changes
Inline
Side-by-side
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
...
...
@@ -18,13 +18,19 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
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
.
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/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
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
|
...
...
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
$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
Supports
Markdown
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