diff --git a/files/provision.sh b/files/provision.sh index 506ac9e..afd609f 100755 --- a/files/provision.sh +++ b/files/provision.sh @@ -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 diff --git a/packer/README.md b/packer/README.md index f9bd5a1..e2db3ca 100644 --- a/packer/README.md +++ b/packer/README.md @@ -17,19 +17,29 @@ export GITHUB_API_TOKEN= # 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= @@ -37,9 +47,6 @@ export GITHUB_API_TOKEN= # Enter the packer build directory cd kdk/packer -# Validate the Packer template -make validate - # Build the box make clean build_hyperv ``` diff --git a/packer/Vagrantfile_hyperv.tmpl b/packer/Vagrantfile_hyperv.tmpl index 9112d6a..11b3e78 100644 --- a/packer/Vagrantfile_hyperv.tmpl +++ b/packer/Vagrantfile_hyperv.tmpl @@ -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 diff --git a/packer/packer_hyperv.json b/packer/packer_hyperv.json index 82e2ab2..8a6324d 100644 --- a/packer/packer_hyperv.json +++ b/packer/packer_hyperv.json @@ -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": [