Skip to content

Commit

Permalink
Fixed hyperv builds
Browse files Browse the repository at this point in the history
  • Loading branch information
dcwangmit01 authored and hangxie committed May 2, 2020
1 parent 84d62a7 commit 0baa087
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
4 changes: 4 additions & 0 deletions files/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ function vagrant() {
exit_if_provisioned

pushd /tmp
# Disable IPV6 temporarily for the current build
# Building on windows seems to require it because
# it hangs on add-apt-repository ppa...
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
# Remove this workaround after bento releases new hyperv box
vagrant_disable_ssh_password_logins
vagrant_bento_workaround_openssl_bug
Expand Down
23 changes: 15 additions & 8 deletions packer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,36 @@ export GITHUB_API_TOKEN=<token created from https://github.com/settings/tokens>
# Enter the packer build directory
cd kdk/packer

# Validate the Packer template
make validate

# Build the box
make clean build_virtualbox
```

## Windows Hyper-V Build

Before you start the Windows Hyper-V build:

* Disconnect from your corporate VPN.
* Ensure you are building from a wired connection.
* Wireless connections almost always fail because the build is network-intensive.
* Configure Hyper-V network settings.
* The Hyper-V packer build only works if the vagrant VM build machine is directly on the network.
* The packer build is configured to auto-select the network named 'External Switch'.
* Create a new network switch called 'External Switch'
* Ensure the 'External Switch' is set to Bridge Mode.
* Ensure you select the wired physical adapter for the 'External Switch'


```bash
# Start Powershell as Administrator
# Start a bash shell in git
C:\Program Files\git\bin\bash.exe
# Start a bash shell in git (within the Administrator Powershell)
"C:\Program Files\git\bin\bash.exe"

# Set a Github API Token so that API call throttling limits are increased
export GITHUB_API_TOKEN=<token created from https://github.com/settings/tokens>

# Enter the packer build directory
cd kdk/packer

# Validate the Packer template
make validate

# Build the box
make clean build_hyperv
```
Expand Down
20 changes: 16 additions & 4 deletions packer/Vagrantfile_hyperv.tmpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# https://github.com/hashicorp/packer/blob/master/builder/vagrant/step_create_vagrantfile.go#L25

Vagrant.configure("2") do |config|
config.vm.box = "{{.BoxName}}"
config.vm.define "source", autostart: false do |source|
source.vm.box = "{{.SourceBox}}"
config.ssh.insert_key = {{.InsertKey}}
end
config.vm.define "output" do |output|
output.vm.box = "{{.BoxName}}"
output.vm.box_url = "file://package.box"
config.ssh.insert_key = {{.InsertKey}}
end
{{ if ne .SyncedFolder "" -}}
config.vm.synced_folder "{{.SyncedFolder}}", "/vagrant"
config.vm.synced_folder "{{.SyncedFolder}}", "/vagrant"
{{- else -}}
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/vagrant", disabled: true
{{- end}}
config.vm.network 'public_network', bridge: 'Default Switch'

# The line below allows Packer to auto-select the network device
config.vm.network 'public_network', bridge: 'External Switch'
end
5 changes: 3 additions & 2 deletions packer/packer_hyperv.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"type": "vagrant",
"provider": "hyperv",
"box_name": "bento/ubuntu-18.04",
"box_version": "201812.27.0",
"box_version": "201912.13.0",
"source_path": "bento/ubuntu-18.04",
"add_force": true,
"skip_add": true,
"template": "Vagrantfile_hyperv.tmpl",
"communicator": "ssh"
"communicator": "ssh",
"ssh_password": "vagrant"
}
],
"provisioners": [
Expand Down

0 comments on commit 0baa087

Please sign in to comment.