Git Product home page Git Product logo

windows-vagrant's Introduction

This builds Windows 11/2022 base Vagrant boxes using Packer and Hyper-V/libvirt/QEMU/Proxmox VE/VMware vSphere.

Usage

Install a supported hypervisor (e.g. libvirt), packer 1.10+ and vagrant. If you are using Windows and Chocolatey, you can install the tools (you still need to install Hyper-V) from an administrative PowerShell session with:

choco install -y packer vagrant msys2

# configure the msys2 launcher to let the shell inherit the PATH.
$msys2BasePath = 'C:\tools\msys64'
$msys2ConfigPath = "$msys2BasePath\msys2.ini"
[IO.File]::WriteAllText(
    $msys2ConfigPath,
    ([IO.File]::ReadAllText($msys2ConfigPath) `
        -replace '#?(MSYS2_PATH_TYPE=).+','$1inherit')
)

# define a function for easing the execution of bash scripts.
$bashPath = "$msys2BasePath\usr\bin\bash.exe"
function Bash($script) {
    $eap = $ErrorActionPreference
    $ErrorActionPreference = 'Continue'
    try {
        # we also redirect the stderr to stdout because PowerShell
        # oddly interleaves them.
        # see https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin
        echo 'exec 2>&1;set -eu;export PATH="/usr/bin:$PATH";export HOME=$USERPROFILE;' $script | &$bashPath
        if ($LASTEXITCODE) {
            throw "bash execution failed with exit code $LASTEXITCODE"
        }
    } finally {
        $ErrorActionPreference = $eap
    }
}

Bash 'pacman --noconfirm -Sy make zip unzip tar p7zip dos2unix xorriso'

Open a bash shell by starting C:\tools\msys64\mingw64.exe and execute the remaining commands inside it.

To build the base box based on the Windows Server 2022 Evaluation ISO run:

make build-windows-2022-libvirt

If you want to use your own ISO, you need to manually run the packer command, e.g.:

# NB when the windows product key does not match the windows version and edition
#    inside the iso file, the windows setup will fail with the error message:
#       No images are available.
#    inside the windows setup, press shit+f10 to open a command prompt, then
#    verify the available images with:
#       dism -get-imageinfo -imagefile:d:\sources\install.wim
# see https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys
PKR_VAR_iso_url='windows-2022.iso' \
PKR_VAR_iso_checksum='none' \
PKR_VAR_windows_product_key='VDYBN-27WPP-V4HQT-9VMD4-VMK7H' \
  make build-windows-2022-libvirt

NB if the build fails with something like Post-processor failed: write /tmp/packer073329394/packer-windows-2022-amd64-libvirt-1505050546-disk001.vmdk: no space left on device you need to increase your temporary partition size or change its location as described in the packer TMPDIR/TMP environment variable documentation.

NB if you are having trouble building the base box due to floppy drive removal errors try adding, as a workaround, "post_shutdown_delay": "30s", to the windows-2022.pkr.hcl file.

NB the packer logs are saved inside a *-packer.log file (e.g. windows-2022-amd64-libvirt-packer.log).

You can then add the base box to your local vagrant installation with:

vagrant box add -f windows-2022-amd64 windows-2022-amd64-libvirt.box

And test this base box by launching an example Vagrant environment:

cd example
vagrant plugin install vagrant-windows-sysprep
vagrant up --no-destroy-on-error --provider=libvirt
vagrant ssh
exit
vagrant destroy -f
cd ..

NB if you are having trouble running the example with the vagrant libvirt provider check the libvirt logs in the host (e.g. sudo tail -f /var/log/libvirt/qemu/example_default.log) and in the guest (inside C:\Windows\Temp).

Then test with a more complete example:

git clone https://github.com/rgl/customize-windows-vagrant
cd customize-windows-vagrant
vagrant up --no-destroy-on-error --provider=libvirt
vagrant ssh
exit
vagrant destroy -f
cd ..

List this repository dependencies (and which have newer versions):

export GITHUB_COM_TOKEN='YOUR_GITHUB_PERSONAL_TOKEN'
./renovate.sh

libvirt

Build the base box for the vagrant-libvirt provider with:

make build-windows-2022-libvirt

If you want to access the UI run:

spicy --uri 'spice+unix:///tmp/packer-windows-2022-amd64-libvirt-spice.socket'

NB the packer template file defines qemuargs (which overrides the default packer qemu arguments), if you modify it, verify if you also need include the default packer qemu arguments (see builder/qemu/step_run.go or start packer without qemuargs defined to see how it starts qemu).

Proxmox VE usage

Install Proxmox VE.

NB This assumes Proxmox VE was installed alike rgl/proxmox-ve.

Set your Proxmox VE details:

cat >secrets-proxmox.sh <<EOF
export PROXMOX_URL='https://192.168.1.21:8006/api2/json'
export PROXMOX_USERNAME='root@pam'
export PROXMOX_PASSWORD='vagrant'
export PROXMOX_NODE='pve'
EOF
source secrets-proxmox.sh

Create the template:

make build-windows-2022-proxmox

NB There is no way to use the created template with vagrant (the vagrant-proxmox plugin is no longer compatible with recent vagrant versions). Instead, use packer (e.g. like in this repository) or terraform (e.g. see rgl/terraform-proxmox-windows-example).

Hyper-V usage

Install Hyper-V.

Make sure your user is in the Hyper-V Administrators group or you run with Administrative privileges.

Hyper-V automatically creates the Default Switch VM Switch and the vEthernet (Default Switch) network adapter/interface. It provides DHCP, DNS forwarding, and NAT internet access. But it cannot be configured, and it changes the assigned IP addresses at every boot; this makes it unusable for me. Instead you should run your own DHCP service and NAT virtual network.

Create the Vagrant vSwitch and NAT network in a PowerShell with Administrative privileges:

$name = 'Vagrant'
$ipAddress = '192.168.192.1'
$ipAddressPrefix = '24'

# create the vSwitch.
$vmSwitch = New-VMSwitch -SwitchName $name -SwitchType Internal

# reconfigure the vSwitch IP configuration to use a known IP and network and disable IPv6.
$netAdapterName = "vEthernet ($name)"
$netAdapter = Get-NetAdapter -Name $netAdapterName
$netAdapter | Disable-NetAdapterBinding -ComponentID ms_tcpip6
$netAdapter | Remove-NetIPAddress -Confirm:$false
$netAdapter | New-NetIPAddress -IPAddress $ipAddress -PrefixLength $ipAddressPrefix

# create the NAT network.
New-NetNat -Name $name -InternalIPInterfaceAddressPrefix "$ipAddress/$ipAddressPrefix"

Then, install and start the WinDHCP DHCP service.

Make sure the Virtual Switch (its vEthernet network adapter) is excluded from the Windows Firewall protected network connections by executing the following commands in a bash shell with Administrative privileges:

PowerShell -Command 'Get-NetFirewallProfile | Select-Object -Property Name,DisabledInterfaceAliases'
PowerShell -Command 'Set-NetFirewallProfile -DisabledInterfaceAliases (Get-NetAdapter -name "vEthernet*" | Where-Object {$_.ifIndex}).InterfaceAlias'

Create the base image in a bash shell with Administrative privileges:

cat >secrets.sh <<'EOF'
# set this value when you need to set the VM Switch Name.
export HYPERV_SWITCH_NAME='Vagrant'

# set this value when you need to set the VM VLAN ID.
export HYPERV_VLAN_ID=''

# set the credentials that the guest will use
# to connect to this host smb share.
# NB you should create a new local user named _vagrant_share
#    and use that one here instead of your user credentials.
# NB it would be nice for this user to have its credentials
#    automatically rotated, if you implement that feature,
#    let me known!
export VAGRANT_SMB_USERNAME='_vagrant_share'
export VAGRANT_SMB_PASSWORD=''

# remove the virtual switch from the windows firewall.
# NB execute if the VM fails to obtain an IP address from DHCP.
PowerShell -Command 'Set-NetFirewallProfile -DisabledInterfaceAliases (Get-NetAdapter -name "vEthernet*" | Where-Object {$_.ifIndex}).InterfaceAlias'
EOF
source secrets.sh
time make build-windows-2022-hyperv

Try the example guest:

NB You will need Administrative privileges to create the SMB share.

cd example
# grant $VAGRANT_SMB_USERNAME full permissions to the
# current directory.
# NB you must first install the Carbon PowerShell module
#    with choco install -y carbon.
# TODO set VM screen resolution.
PowerShell -Command 'Import-Module Carbon; Grant-Permission . $env:VAGRANT_SMB_USERNAME FullControl'
vagrant up --no-destroy-on-error --provider=hyperv
vagrant ssh
exit
vagrant destroy -f

VMware vSphere

Download the Windows Evaluation ISO (you can find the full iso URL in the windows-2022-vsphere.pkr.hcl file) and place it inside the datastore as defined by the vsphere_iso_url user variable that is inside the packer template.

Download the VMware Tools VMware-tools-windows-<SAME_VERSION_AS_IN_PACKER_TEMPLATE>.iso file into the datastore defined by the vsphere_tools_iso_url user variable that is inside the packer template.

Download govc and place it inside your /usr/local/bin directory.

Install the vsphere vagrant plugin, set your vSphere details, and test the connection to vSphere:

sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
vagrant plugin install vagrant-vsphere
vagrant plugin install vagrant-windows-sysprep
cat >secrets.sh <<'EOF'
export GOVC_INSECURE='1'
export GOVC_HOST='vsphere.local'
export GOVC_URL="https://$GOVC_HOST/sdk"
export GOVC_USERNAME='[email protected]'
export GOVC_PASSWORD='password'
export GOVC_DATACENTER='Datacenter'
export GOVC_CLUSTER='Cluster'
export GOVC_DATASTORE='Datastore'
export VSPHERE_ESXI_HOST='esxi.local'
export VSPHERE_TEMPLATE_FOLDER='test/templates'
# NB the VSPHERE_TEMPLATE_NAME last segment MUST match the
#    builders.vm_name property inside the packer template.
export VSPHERE_TEMPLATE_NAME="$VSPHERE_TEMPLATE_FOLDER/windows-2022-amd64-vsphere"
export VSPHERE_TEMPLATE_IPATH="//$GOVC_DATACENTER/vm/$VSPHERE_TEMPLATE_NAME"
export VSPHERE_VM_FOLDER='test'
export VSPHERE_VM_NAME='windows-2022-vagrant-example'
export VSPHERE_VLAN='packer'
# set the credentials that the guest will use
# to connect to this host smb share.
# NB you should create a new local user named _vagrant_share
#    and use that one here instead of your user credentials.
# NB it would be nice for this user to have its credentials
#    automatically rotated, if you implement that feature,
#    let me known!
export VAGRANT_SMB_USERNAME='_vagrant_share'
export VAGRANT_SMB_PASSWORD=''
EOF
source secrets.sh
# see https://github.com/vmware/govmomi/blob/master/govc/USAGE.md
govc version
govc about
govc datacenter.info # list datacenters
govc find # find all managed objects

Build the base box with:

make build-windows-2022-vsphere

Try the example guest:

source secrets.sh
cd example
echo $VSPHERE_TEMPLATE_NAME # check if you are using the expected template.
vagrant up --no-destroy-on-error --provider=vsphere
vagrant ssh
exit
vagrant destroy -f

Non-Administrator account

The above example uses the administrator account, but you can use a less privileged account like in the following example.

Example

First, review the glossary:

Privilege
The ability to perform a specific action or read a specific property.
Role
A collection of privileges. Roles provide a way to aggregate all the individual privileges that are required to perform a higher-level task.
Permission
Consists of a user or group and an assigned role for an inventory object.

Then follow the next steps to create an example configuration.

In the vSphere Single Sign-On (SSO) configuration page create a Vagrants group and add your non-administrator user to it.

In the vSphere Access Control page create a Vagrant role with the privileges:

  • Datastore
    • Allocate space
  • Network
    • Assign network
  • Resource
    • Assign virtual machine to resource pool
  • Virtual machine
    • Provisioning
      • Deploy template

In vSphere configure the following Inventory Objects permissions:

Inventory Object Role Principal (User or Group) Propagate
Datacenter Vagrant VSPHERE.LOCAL\Vagrants yes
test Administrator VSPHERE.LOCAL\Vagrants yes

NB test is a folder that will store the virtual machines launched by vagrant.

For more information see the vSphere Virtual Machine Administration/Required Privileges for Common Tasks document in the vSphere Virtual Machine Administration manual.

SSH access

You can connect to this machine through SSH to run a remote command, e.g.:

ssh -p 2222 vagrant@localhost "whoami /all"

NB the exact SSH address and port can be obtained with vagrant ssh-config.

NB we cannot use the vagrant SMB shared folder type when using the winssh communicator; it will fail to mount the shared folder with the error:

cmdkey /add:192.168.1.xxx /user:xxx /pass:"*****"
CMDKEY: Credentials cannot be saved from this logon session.

NB this is a Windows design restriction that prevents remote network logon sessions from accessing certain parts of the system.

NB this is why the default vagrant box communicator is winrm.

PowerShell Remoting over SSH

You can connect to this machine through PowerShell Remoting over SSH. In a Linux (or Windows) PowerShell 7 session execute, e.g.:

Enter-PSSession -HostName vagrant@localhost:2222
$PSVersionTable
whoami /all
exit

WinRM access

You can connect to this machine through WinRM to run a remote command. In a Windows Command Prompt session execute, e.g.:

winrs -r:localhost:55985 -u:vagrant -p:vagrant "whoami /all"

NB the exact local WinRM port should be displayed by vagrant, in this case:

==> default: Forwarding ports...
    default: 5985 (guest) => 55985 (host) (adapter 1)

PowerShell Remoting over WinRM

You can connect to this machine through PowerShell Remoting over WinRM. In a Windows PowerShell 7 session execute, e.g.:

# Configure this machine WinRM client to trust all remote servers.
# NB Since this local client machine is not in the AD nor its using HTTPS to
#    access the server, we must configure it to trust the server, or in this
#    case, trust all servers.
Set-Item WSMan:\localhost\Client\TrustedHosts -Value '*' -Force

# Open a session and execute commands remotely.
# NB To open a PowerShell 5 session, remove the -ConfigurationName argument.
Enter-PSSession -ConfigurationName PowerShell.7 -ComputerName localhost -Port 55985 -Credential vagrant
Get-PSSessionConfiguration  # show the available configurations.
$PSVersionTable             # show the powershell version.
whoami /all                 # show the user permissions.
exit                        # exit the session.

WinRM and UAC (aka LUA)

This base image uses WinRM. WinRM poses several limitations on remote administration, those were worked around by disabling User Account Control (UAC) (aka Limited User Account (LUA)) in autounattend.xml and UAC remote restrictions in provision-winrm.ps1.

If needed, you can later enable them with:

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' -Name EnableLUA -Value 1
Set-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies\System' -Name EnableLUA -Value 1
Remove-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' -Name LocalAccountTokenFilterPolicy
Restart-Computer

Or disable them with:

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' -Name EnableLUA -Value 0
Set-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies\System' -Name EnableLUA -Value 0
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' -Name LocalAccountTokenFilterPolicy -Value 1 -Force
Restart-Computer

Windows Unattended Installation

When Windows boots from the installation media its Setup application loads the a:\autounattend.xml file. It contains all the answers needed to automatically install Windows without any human intervention. For more information on how this works see OEM Windows Deployment and Imaging Walkthrough.

Where there is a problem with the setup, you should look into the Setup log files (Windows Preinstallation Environment phase) by pressing Ctrl+F10 to open a Command Prompt, and then use notepad.exe to open the Setup log files.

autounattend.xml was generated with the Windows System Image Manager (WSIM) application that is included in the Windows Assessment and Deployment Kit (ADK).

Windows ADK

To create, edit and validate the a:\autounattend.xml file you need to install the Deployment Tools that are included in the Windows ADK.

If you are having trouble installing the ADK (adksetup) or running WSIM (imgmgr) when your machine is on a Windows Domain and the log has:

Image path is [\??\C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\DISM\wimmount.sys]
Could not acquire privileges; GLE=0x514
Returning status 0x514

It means there's a group policy that is restricting your effective permissions, for an workaround, run adksetup and imgmgr from a SYSTEM shell, something like:

psexec -s -d -i cmd
adksetup
cd "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\WSIM"
imgmgr

For more information see Error installing Windows ADK.

windows-vagrant's People

Contributors

kampka avatar rgl avatar ryanfitzsimon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windows-vagrant's Issues

make build-windows-windows-2019-virtualbox shows /bin/sh: line 1: 7z: command not found

Hi.

I get an error message when I execute make build-windows-2019-virtualbox command

This is the error message:

rm -rf drivers.tmp
mkdir -p drivers.tmp
wget -P drivers.tmp https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.190-1/virtio-win-0.1.190.iso
--2021-01-07 14:38:58-- https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.190-1/virtio-win-0.1.190.iso
Resolving fedorapeople.org (fedorapeople.org)... 152.19.134.199, 2610:28:3090:3001:5054:ff:fea7:9474
Connecting to fedorapeople.org (fedorapeople.org)|152.19.134.199|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 501745664 (479M) [application/octet-stream]
Saving to: ‘drivers.tmp/virtio-win-0.1.190.iso’

virtio-win-0.1.190.iso 100%[======================================================================================>] 478.50M 19.2MB/s in 47s

2021-01-07 14:39:46 (10.1 MB/s) - ‘drivers.tmp/virtio-win-0.1.190.iso’ saved [501745664/501745664]

7z x -odrivers.tmp drivers.tmp/virtio-win-*.iso
/bin/sh: line 1: 7z: command not found
make: *** [Makefile:164: drivers] Error 127

To fix this issue: In the Mingw64 Bash Shell, I installed p7zip with this command:

Bash 'pacman --noconfirm -Sy p7zip'

I just wanted to let you know so you can decide if you want to reproduce the problem and the solution and decide if you want to update the readme/instructions:-)

Best Regards

Run .NET Runtime Optimization (ngen)

Hey there,
your stuff was a nice knowledge base for me to build windows ami with packer.
You might also want to include forcing the .NET compiler to run after installation. This is what i use before sysprep the image (in my case EC2 AMI):

  ## Force .NET Runtime Optimization service (mscorsvw.exe) to run compiler now (usually required after updates and installations)
  # running it now prevents compiling on each started ec2 instance based on it
  # Run for all archs (32 and 64 bit) and versions
  Get-Item  $([environment]::GetEnvironmentVariable("windir","Machine") + "\Microsoft.NET\*\*\ngen.exe") | ForEach-Object {
    Start-Process -NoNewWindow -PassThru -Wait -FilePath $_.FullName -ArgumentList "executeQueuedItems /silent"
  }

provision-openssh.ps1 fails when run from autounattend

I noticed OpenSSH not being installed even though the builds ran through fine. In the setupact.log everything seems to be fine. When run manually the script runs through without problems as well. I don't know how to get more verbose logging :/

My workaround so far is to comment it out in provision-autounattend.ps1 and run it as a packer provision step.
Edit: oh, that fails as well with curious reasons for doing so:

==> proxmox-iso.windows-10-21h2-amd64: Provisioning with powershell script: ../scripts/provision-openssh.ps1
2023/04/11 19:48:12 packer-provisioner-powershell plugin: Opening ../scripts/provision-openssh.ps1 for reading
2023/04/11 19:48:12 packer-provisioner-powershell plugin: Uploading env vars to c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1
2023/04/11 19:48:12 packer-provisioner-powershell plugin: [INFO] 118 bytes written for 'uploadData'
2023/04/11 19:48:12 [INFO] 118 bytes written for 'uploadData'
2023/04/11 19:48:12 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:12 Uploading file to 'c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1'
2023/04/11 19:48:22 packer-provisioner-powershell plugin: [INFO] 6062 bytes written for 'uploadData'
2023/04/11 19:48:22 [INFO] 6062 bytes written for 'uploadData'
2023/04/11 19:48:22 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:22 Uploading file to 'c:/Windows/Temp/script-64359d5c-f051-c72a-b84f-495c81f719c3.ps1'
2023/04/11 19:48:57 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:57 [INFO] starting remote command: pwsh -executionpolicy bypass -command "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1; &'c:/Windows/Temp/script-64359d5c-f051-c72a-b84f-495c81f719c3.ps1'; exit $LastExitCode }"
2023/04/11 19:48:58 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:58 [INFO] command 'pwsh -executionpolicy bypass -command "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1; &'c:/Windows/Temp/script-64359d5c-f051-c72a-b84f-495c81f719c3.ps1'; exit $LastExitCode }"' exited with code: 0
2023/04/11 19:48:58 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:58 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/11 19:48:58 [INFO] 0 bytes written for 'stdout'
2023/04/11 19:48:58 [INFO] 303 bytes written for 'stderr'
2023/04/11 19:48:58 [INFO] RPC client: Communicator ended with: 0
2023/04/11 19:48:58 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/11 19:48:58 packer-provisioner-powershell plugin: [INFO] 0 bytes written for 'stdout'
2023/04/11 19:48:58 packer-provisioner-powershell plugin: [INFO] 303 bytes written for 'stderr'
2023/04/11 19:48:58 packer-provisioner-powershell plugin: [INFO] RPC client: Communicator ended with: 0
==> proxmox-iso.windows-10-21h2-amd64: .: The term 'c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program.
2023/04/11 19:48:58 packer-provisioner-powershell plugin: c:/Windows/Temp/script-64359d5c-f051-c72a-b84f-495c81f719c3.ps1 returned with exit code 0
==> proxmox-iso.windows-10-21h2-amd64: Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2023/04/11 19:48:58 packer-provisioner-powershell plugin: [INFO] 511 bytes written for 'uploadData'
2023/04/11 19:48:58 [INFO] 511 bytes written for 'uploadData'
2023/04/11 19:48:58 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:58 Uploading file to 'c:/Windows/Temp/packer-cleanup-64359d5c-9dcd-971a-6265-5b6602982e70.ps1'
2023/04/11 19:49:04 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:49:04 [INFO] starting remote command: pwsh -executionpolicy bypass -command "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1; &'c:/Windows/Temp/packer-cleanup-64359d5c-9dcd-971a-6265-5b6602982e70.ps1'; exit $LastExitCode }"
2023/04/11 19:49:05 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:49:05 [INFO] command 'pwsh -executionpolicy bypass -command "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1; &'c:/Windows/Temp/packer-cleanup-64359d5c-9dcd-971a-6265-5b6602982e70.ps1'; exit $LastExitCode }"' exited with code: 0
2023/04/11 19:49:05 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:49:05 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/11 19:49:05 [INFO] 0 bytes written for 'stdout'
2023/04/11 19:49:05 [INFO] 303 bytes written for 'stderr'
2023/04/11 19:49:05 [INFO] RPC client: Communicator ended with: 0
2023/04/11 19:49:05 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/11 19:49:05 packer-provisioner-powershell plugin: [INFO] 0 bytes written for 'stdout'
2023/04/11 19:49:05 packer-provisioner-powershell plugin: [INFO] 303 bytes written for 'stderr'
2023/04/11 19:49:05 packer-provisioner-powershell plugin: [INFO] RPC client: Communicator ended with: 0
==> proxmox-iso.windows-10-21h2-amd64: .: The term 'c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program.
2023/04/11 19:49:05 [INFO] (telemetry) ending powershell
==> proxmox-iso.windows-10-21h2-amd64: Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
==> proxmox-iso.windows-10-21h2-amd64: Stopping VM

After switching on the debug flags, it shows the script silently exiting after

    proxmox-iso.windows-10-21h2-amd64: DEBUG:   70+  >>>> $windowsOpenSshCapabilities = Get-WindowsCapability -Online -Name 'OpenSSH.*' | Where-Object {$_.State -ne 'NotPresent'}
    proxmox-iso.windows-10-21h2-amd64: 
2023/04/12 00:13:00 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/12 00:13:00 [INFO] command 'pwsh -executionpolicy bypass -command "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};Set-PsDebug -Trace 1;. c:/Windows/Temp/packer-ps-env-vars-6435db5a-c007-eecc-99ad-e36c813e4adf.ps1; &'c:/Windows/Temp/script-6435db5a-586f-9950-b5e0-c9f1c873fcf8.ps1'; exit $LastExitCode }"' exited with code: 0
2023/04/12 00:13:00 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/12 00:13:00 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/12 00:13:00 [INFO] 4119 bytes written for 'stdout'
2023/04/12 00:13:00 [INFO] 0 bytes written for 'stderr'
2023/04/12 00:13:00 [INFO] RPC client: Communicator ended with: 0
2023/04/12 00:13:00 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/12 00:13:00 packer-provisioner-powershell plugin: [INFO] 4119 bytes written for 'stdout'
2023/04/12 00:13:00 packer-provisioner-powershell plugin: [INFO] 0 bytes written for 'stderr'
2023/04/12 00:13:00 packer-provisioner-powershell plugin: [INFO] RPC client: Communicator ended with: 0
2023/04/12 00:13:00 packer-provisioner-powershell plugin: c:/Windows/Temp/script-6435db5a-586f-9950-b5e0-c9f1c873fcf8.ps1 returned with exit code 0
2023/04/12 00:13:00 [INFO] (telemetry) ending powershell
==> proxmox-iso.windows-10-21h2-amd64: Stopping VM

as said, manually, there are no hickups. I wonder which account actually runs the script, a) in the autoattend.xml b) as a packer provisioner step.

Initial boot of Windows 2019 installation failed

I tried to create a Windows 2019 VM by running make build-windows-2019-virtualbox.

This created and started a VM, but it failed to boot with error message FATAL: Could not read from the boot medium! System halted..

I assume the reason is that the ISO images (VBoxGuestAdditions.iso and the installation disk) are added to the SATA Controller in the wrong order:

  • VBoxGuestAdditions.iso: port 14
  • installation disk: port 15
    The VM tried to boot from the first iso image VBoxGuestAdditions.iso and failed.

Workaround

I used the following workaround:

  1. Stop the VM (keeping the make command running)
  2. Manually edit the VM in VirtualBox, swapping the SATA ports of the two iso images so that the installation iso comes first
  3. Start the VM

Installation continued successfully.

Note

Using other SATA ports than 14 and 15 caused the installation to fail after 1:12h at the very end:

==> virtualbox-iso.windows-2019-amd64: Gracefully halting virtual machine...
    virtualbox-iso.windows-2019-amd64: Removing floppy drive...
==> virtualbox-iso.windows-2019-amd64: Error detaching ISO: VBoxManage error: VBoxManage: error: No storage device attached to device slot 0 on port 15 of controller 'SATA Controller'
==> virtualbox-iso.windows-2019-amd64: VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component SessionMachine, interface IMachine, callee nsISupports
==> virtualbox-iso.windows-2019-amd64: VBoxManage: error: Context: "DetachDevice(Bstr(pszCtl).raw(), port, device)" at line 403 of file VBoxManageStorageController.cpp
==> virtualbox-iso.windows-2019-amd64: Error detaching ISO: VBoxManage error: VBoxManage: error: No storage device attached to device slot 0 on port 15 of controller 'SATA Controller'
==> virtualbox-iso.windows-2019-amd64: VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component SessionMachine, interface IMachine, callee nsISupports
==> virtualbox-iso.windows-2019-amd64: VBoxManage: error: Context: "DetachDevice(Bstr(pszCtl).raw(), port, device)" at line 403 of file VBoxManageStorageController.cpp
==> virtualbox-iso.windows-2019-amd64: Step "StepRemoveDevices" failed, aborting...

Environment:

  • macOS 11.6
  • Vagrant 2.2.18
  • Packer 1.7.7
  • VirtualBox 6.1.26

winrm and sshd services delayed-auto start

delayed-auto takes 3 minutes to boot the VM. This is not acceptable when booting a fresh VM for CICD integration tests. When I set auto start for both of these services, the VM boots within 30 seconds and seems to work fine.

Provision scripts for winrm and sshd mention that using auto start is "unreliable". Could you elaborate whats unreliable about it? Do you think its possible to fix the underlying issue of this unreliability?

https://github.com/rgl/windows-vagrant/blob/master/provision-winrm.ps1#L48
https://github.com/rgl/windows-vagrant/blob/master/provision-openssh.ps1#L116

vmdk: no space left on device

Hello! I tried to create this box but I got an error during the post-processing step:

==> windows-2016-amd64-virtualbox: Unregistering and deleting virtual machine...
==> windows-2016-amd64-virtualbox: Running post-processor: vagrant
==> windows-2016-amd64-virtualbox (vagrant): Creating Vagrant box for 'virtualbox' provider
    windows-2016-amd64-virtualbox (vagrant): Copying from artifact: output-windows-2016-amd64-virtualbox/packer-windows-2016-amd64-virtualbox-1505050546-disk001.vmdk
Build 'windows-2016-amd64-virtualbox' errored: 1 error(s) occurred:

* Post-processor failed: write /tmp/packer073329394/packer-windows-2016-amd64-virtualbox-1505050546-disk001.vmdk: no space left on device

==> Some builds didn't complete successfully and had errors:
--> windows-2016-amd64-virtualbox: 1 error(s) occurred:

* Post-processor failed: write /tmp/packer073329394/packer-windows-2016-amd64-virtualbox-1505050546-disk001.vmdk: no space left on device

==> Builds finished but no artifacts were created.

Do you know what might have caused this / how I can resolve? I know it's not my computer's disk because I have ~100GB free.

Invalid link in doc concerning TMP/TMPDIR packer env variable

The README says

NB if the build fails with something like Post-processor failed: write /tmp/packer073329394/packer-windows-2022-amd64-virtualbox-1505050546-disk001.vmdk: no space left on device you need to increase your temporary partition size or change its location as described in the packer TMPDIR/TMP environment variable documentation.

But the link is not valid anymore. I tried searching their doc for the new location, but couldn't find it. Is these variables still supported?

optimize.ps1 not working on Windows 10 2004

Hi,
This bunch of script make otimize.ps1 runs forever on Windows 10 2004.

Write-Host 'Running Automatic Maintenance...'
MSchedExe.exe Start
Wait-Condition {@(Get-ScheduledTasks | Where-Object {($.State -ge 4) -and (Test-IsMaintenanceTask $.XML)}).Count -eq 0} -DebounceSeconds 60

It is fine for Windows 2019 though.

Any idea?

Thanks

packer: command not found

Hello, after following your readme using the script inside provided I opened the shell session in :

C:\tools\msys64\mingw64.exe

Then i ran make build-windows-2019-virtualbox and got this error :

rm -f windows-2019-amd64-virtualbox.box
CHECKPOINT_DISABLE=1 PACKER_LOG=1 PACKER_LOG_PATH=windows-2019-amd64-virtualbox-packer-init.log \
        packer init windows-2019.pkr.hcl
/bin/sh: line 1: packer: command not found
make: *** [Makefile:65: windows-2019-amd64-virtualbox.box] Error 127

Any Idea why this would happen ?

Packer - 1.7.8
Vagrant - 2.2.19

Thank you.

error when trying to use config.vm.synced_folder with rsync

Hi, thanks for making this project, it's very cool to be able to build own Windows base box!

I have done so for Win 2016 for libvirt but when I try to in the following Vagrantfile

Vagrant.configure("2") do |config|

  config.vagrant.plugins = [ "vagrant-libvirt" ]

  # we are using our freshly made Win 2016 base box
  config.vm.define :test_vm do |test_vm|
    test_vm.vm.box = "windows-2016-amd64"
    test_vm.vm.hostname = "littlewin"
  end

  config.vm.network "private_network", type: "dhcp"
  config.vm.synced_folder "./", "c:/vagrant", type: "rsync"

  # details to the libvirt provider
  config.vm.provider :libvirt do |libvirt|
    libvirt.host = "littlewin"
    libvirt.driver = "kvm"
    libvirt.memory = 2048
    libvirt.cpus = 2
  end

  #
  # Run Ansible from the Vagrant Host
  #
  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "playbook.yml"
  end

end

the VM's startup fails with this error:

θ75° [luke:~/work/projects/vagrant-win2016] master(+15/-1)* 1 ± vagrant up
Bringing machine 'test_vm' up with 'libvirt' provider...
==> test_vm: Creating image (snapshot of base box volume).
==> test_vm: Creating domain with the following settings...
==> test_vm:  -- Name:              vagrant-win2016_test_vm
==> test_vm:  -- Domain type:       kvm
==> test_vm:  -- Cpus:              2
==> test_vm:  -- Feature:           acpi
==> test_vm:  -- Feature:           apic
==> test_vm:  -- Feature:           pae
==> test_vm:  -- Memory:            2048M
==> test_vm:  -- Management MAC:    
==> test_vm:  -- Loader:            
==> test_vm:  -- Nvram:             
==> test_vm:  -- Base box:          windows-2016-amd64
==> test_vm:  -- Storage pool:      default
==> test_vm:  -- Image:             /var/lib/libvirt/images/vagrant-win2016_test_vm.img (60G)
==> test_vm:  -- Volume Cache:      default
==> test_vm:  -- Kernel:            
==> test_vm:  -- Initrd:            
==> test_vm:  -- Graphics Type:     spice
==> test_vm:  -- Graphics Port:     -1
==> test_vm:  -- Graphics IP:       127.0.0.1
==> test_vm:  -- Graphics Password: Not defined
==> test_vm:  -- Video Type:        qxl
==> test_vm:  -- Video VRAM:        9216
==> test_vm:  -- Sound Type:	
==> test_vm:  -- Keymap:            en-us
==> test_vm:  -- TPM Path:          
==> test_vm:  -- INPUT:             type=tablet, bus=usb
==> test_vm:  -- CHANNEL:             type=unix, mode=
==> test_vm:  -- CHANNEL:             target_type=virtio, target_name=org.qemu.guest_agent.0
==> test_vm:  -- CHANNEL:             type=spicevmc, mode=
==> test_vm:  -- CHANNEL:             target_type=virtio, target_name=com.redhat.spice.0
==> test_vm: Creating shared folders metadata...
==> test_vm: Starting domain.
==> test_vm: Waiting for domain to get an IP address...
==> test_vm: Waiting for SSH to become available...



==> test_vm: Setting hostname...
==> test_vm: Waiting for machine to reboot...
==> test_vm: Forwarding ports...
==> test_vm: 5985 (guest) => 55985 (host) (adapter eth0)
==> test_vm: 5986 (guest) => 55986 (host) (adapter eth0)
==> test_vm: Configuring and enabling network interfaces...
==> test_vm: Rsyncing folder: /home/luke/work/projects/vagrant-win2016/ => /cygdrive/c/vagrant
==> test_vm: Exporting NFS shared folders...
==> test_vm: Preparing to edit /etc/exports. Administrator privileges will be required...
==> test_vm: Clearing any previously set forwarded ports...
==> test_vm: Removing domain...
Traceback (most recent call last):
	58: from /home/luke/.vagrant.d/gems/2.7.2/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
	57: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'
	56: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `action'
	55: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `call'
	54: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/environment.rb:613:in `lock'
	53: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/machine.rb:212:in `block in action'
	52: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/machine.rb:240:in `action_raw'
	51: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
	50: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
	49: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
	48: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:116:in `call'
	47: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	46: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
	45: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	44: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/box_check_outdated.rb:36:in `call'
	43: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	42: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/call.rb:53:in `call'
	41: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
	40: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
	39: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
	38: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:116:in `call'
	37: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	36: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:107:in `block in finalize_action'
	35: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	34: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/set_name_of_domain.rb:32:in `call'
	33: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	32: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/handle_storage_pool.rb:57:in `call'
	31: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	30: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
	29: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	28: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/handle_box_image.rb:127:in `call'
	27: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	26: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/create_domain_volume.rb:87:in `call'
	25: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	24: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/create_domain.rb:374:in `call'
	23: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	22: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/provision.rb:80:in `call'
	21: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	20: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb:12:in `call'
	19: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	18: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/synced_folders/nfs/action_cleanup.rb:25:in `call'
	17: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	16: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/synced_folder_cleanup.rb:28:in `call'
	15: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	14: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/delayed.rb:19:in `call'
	13: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	12: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/synced_folders.rb:90:in `call'
	11: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/synced_folders.rb:90:in `each'
	10: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/synced_folders.rb:93:in `block in call'
	 9: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/synced_folders/nfs/synced_folder.rb:79:in `enable'
	 8: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/synced_folders/nfs/synced_folder.rb:79:in `synchronize'
	 7: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/synced_folders/nfs/synced_folder.rb:81:in `block in enable'
	 6: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/environment.rb:613:in `lock'
	 5: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/synced_folders/nfs/synced_folder.rb:83:in `block (2 levels) in enable'
	 4: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/capability_host.rb:111:in `capability'
	 3: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/capability_host.rb:111:in `call'
	 2: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/hosts/linux/cap/nfs.rb:82:in `nfs_export'
	 1: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/hosts/linux/cap/nfs.rb:186:in `nfs_write_exports'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/hosts/linux/cap/nfs.rb:186:in `stat': No such file or directory @ rb_file_s_stat - /etc/exports (Errno::ENOENT)

It seems that Vagrant is still trying to employ NFS somehow, even though I tell it to use rsync:

...
  config.vm.synced_folder "./", "c:/vagrant", type: "rsync",#, :nfs => !RUBY_PLATFORM.downcase.include?("w32")
...

and I do see it using RSync in the log:

==> test_vm: Rsyncing folder: /home/luke/work/projects/vagrant-win2016/ => /cygdrive/c/vagrant

so - I am puzzled! :)

How to downgrade PowerShell in Windows 2012?

Hello! Is it possible to downgrade PowerShell (current version is 5.1, expected version is 4.0) in rgl/windows-server-2012-r2-standard-amd64 box?

I've tried wusa.exe /uninstall /KB:3191564 but it fails. So far it seems that the only option for me is to repack the box without running provision-powershell.ps1.

Add clean target to Makefile

These invocations of rm -rf $@ for each target in the Makefile should be put in a separate clean target. That way it doesn't remove everything each time the user re-runs make.

This would be especially helpful for all of the large files that are downloaded during the build process.

error when attempting to rsync a synced folder

BOX successfully built!
vagrant box add -f windows-2019-amd64 windows-2019-amd64-vsphere.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'windows-2019-amd64' (v0) for provider: 
    box: Unpacking necessary files from: file:///home/goad/windows-vagrant/windows-2019-amd64-vsphere.box
==> box: Successfully added box 'windows-2019-amd64' (v0) for 'vsphere'!
vagrant box list
windows-2019-amd64 (vsphere, 0)

❯ cd example
❯ vagrant up
==> vagrant: You have requested to enabled the experimental flag with the following features:
==> vagrant: 
==> vagrant: Features:  typed_triggers
==> vagrant: 
==> vagrant: Please use with caution, as some of the features may not be fully
==> vagrant: functional yet.
Bringing machine 'default' up with 'vsphere' provider...
==> default: Setting custom memory: 4096
==> default: Setting custom cpu count: 4
==> default: Calling vSphere CloneVM with the following settings:
==> default:  -- Template VM: Kore/vm/Modeles/Packer/windows-2019-amd64-vsphere
==> default:  -- Target VM: Kore/vm/GOAD/windows-2019-vagrant-example
==> default: New virtual machine successfully cloned
==> default: Waiting for the machine to report its IP address...
    default: Timeout: 240 seconds
    default: IP: 1.25.52.158
==> default: Waiting for machine to boot. This may take a few minutes...
    default: WinRM address: 1.25.52.158:5985
    default: WinRM username: vagrant
    default: WinRM execution_time_limit: PT2H
    default: WinRM transport: negotiate
==> default: Machine booted and ready!
==> default: Setting hostname...
==> default: Waiting for machine to reboot...
==> default: Rsyncing folder: /home/goad/windows-vagrant/example/ => /vagrant
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /home/goad/windows-vagrant/example/
Guest path: /vagrant
Command: "rsync" "--verbose" "--archive" "--delete" "-z" "--copy-links" "--no-owner" "--no-group" "-e" "ssh -p 22 -o LogLevel=FATAL   -o ControlMaster=auto -o ControlPath=/tmp/vagrant-rsync-20221112-199115-1lwg5d2 -o ControlPersist=10m  -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i '/home/goad/.vagrant.d/insecure_private_key'" "--exclude" ".vagrant/" "/home/goad/windows-vagrant/example/" "[email protected]:/vagrant"
Error: rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.3]

can i skip the folder sync?
Regard.

Windows 2016 build issues on ubuntu host...

Hi, I have both virtualbox and libvirt installed, trying to build your VMs for both virt providers.

Not sure what's going on, can you shed some light?

LIBVIRT: make build-windows-2016-libvirt

==> qemu.windows-2016-amd64: Waiting for SSH to become available...
==> qemu.windows-2016-amd64: Connected to SSH!
==> qemu.windows-2016-amd64: Provisioning with Powershell...
==> qemu.windows-2016-amd64: Provisioning with powershell script: disable-windows-updates.ps1
==> qemu.windows-2016-amd64: Error processing command: Error uploading ps script containing env vars: Process exited with status 1
==> qemu.windows-2016-amd64: Step "StepProvision" failed, aborting...

Leaves the VM running, sitting with windows UI open and functional if connected to VNC through the build process.

VIRTUALBOX: make build-windows-2016-virtualbox

==> virtualbox-iso.windows-2016-amd64: Waiting for SSH to become available...
==> virtualbox-iso.windows-2016-amd64: Connected to SSH!
==> virtualbox-iso.windows-2016-amd64: Uploading VirtualBox version info (6.1.32)
==> virtualbox-iso.windows-2016-amd64: Error uploading VirtualBox version: Process exited with status 1
==> virtualbox-iso.windows-2016-amd64: Step "StepUploadVersion" failed, aborting...

Leaves VM running, looking at virtualbox console, UI seems functional.

Any ideas?

win2016

hi, this can be adapt to work with windows server 2016?
when i try, i got some autounatended error( or with another iso) but my files are working with packer vsphere-iso directly.
Regards

provisioner type not found: windows-update

Hi,

When I run packer I have error as below

packer build -only=windows-2016-amd64-virtualbox windows-2016.json
Failed to initialize build 'windows-2016-amd64-virtualbox': provisioner type not found: windows-update
windows-2016-amd64-virtualbox output will be in this color.

System Windows 10 Enterprise, 1607
Packages installed using choco. I even check with packer 1.2.2, still it doesn't work

libvirt-fix-cpu-driver.ps1 is missing

Hi, just tried to use your script but libvirt-fix-cpu-driver.ps1 seems to be missing from the repo.

packer tries to use the file when running packer build -only=windows-2016-amd64-virtualbox .\windows-2016.json on a Windows 10 machine from a powershell prompt.

Windows 2016 ISO 404

The iso_url in windows-2016.json is returning a 404 when trying to download the ISO.

Provisioning fails with QEMU 8.1

With upgrade of my system to Fedora 39 and qemu 8.1, provisioning of new vagrant w2k22 boxes using the windows-vagrant scripts stopped working. I've traced it to this qemu issue - https://gitlab.com/qemu-project/qemu/-/issues/2008

The powershell command "Get-CimInstance -Class Win32_ComputerSystemProduct" returns an empty string because of this issue, and this causes scripts to fail.

As a workaround, I change machine type on the windows-2022.pkr.hcl from "q35" to "q35,smbios-entry-point-type=32". I don't know how fast this will be fixed in qemu and backported to Linux distros. If it is not fixed, consider making this a permanent change.

License

Please add license information

virtualbox-iso.windows-2022-amd64: error downloading ISO: [read tcp read: connection reset by peer]

virtualbox-iso.windows-2022-amd64: output will be in this color.

==> virtualbox-iso.windows-2022-amd64: Retrieving Guest additions
==> virtualbox-iso.windows-2022-amd64: Trying /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-iso.windows-2022-amd64: Trying /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-iso.windows-2022-amd64: /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso => /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-iso.windows-2022-amd64: Retrieving ISO
==> virtualbox-iso.windows-2022-amd64: Trying https://software-static.download.prss.microsoft.com/sg/download/888969d5-f34g-4e03-ac9d-1f9786c66749/SERVER_EVAL_x64FRE_en-us.iso
==> virtualbox-iso.windows-2022-amd64: Trying https://software-static.download.prss.microsoft.com/sg/download/888969d5-f34g-4e03-ac9d-1f9786c66749/SERVER_EVAL_x64FRE_en-us.iso?checksum=sha256%3A3e4fa6d8507b554856fc9ca6079cc402df11a8b79344871669f0251535255325
    virtualbox-iso.windows-2022-amd64: SERVER_EVAL_x64FRE_en-us.iso 1.68 GiB / 4.70 GiB [==============================================>----------------------------------------------------------------------------------]  35.75% 15m3s
==> virtualbox-iso.windows-2022-amd64: Download failed read tcp [2607:fb90:e200:ae63:d935:e425:b834:72dc]:60212->[2606:2800:11f:1cb7:261b:1f9c:2074:3c]:443: read: connection reset by peer
==> virtualbox-iso.windows-2022-amd64: error downloading ISO: [read tcp [2607:fb90:e200:ae63:d935:e425:b834:72dc]:60212->[2606:2800:11f:1cb7:261b:1f9c:2074:3c]:443: read: connection reset by peer]
==> virtualbox-iso.windows-2022-amd64: error downloading ISO: [read tcp [2607:fb90:e200:ae63:d935:e425:b834:72dc]:60212->[2606:2800:11f:1cb7:261b:1f9c:2074:3c]:443: read: connection reset by peer]
==> virtualbox-iso.windows-2022-amd64: Step "StepDownload" failed, aborting...
==> virtualbox-iso.windows-2022-amd64: aborted: skipping cleanup of step "StepDownloadGuestAdditions"
Build 'virtualbox-iso.windows-2022-amd64' errored after 15 minutes 6 seconds: error downloading ISO: [read tcp [2607:fb90:e200:ae63:d935:e425:b834:72dc]:60212->[2606:2800:11f:1cb7:261b:1f9c:2074:3c]:443: read: connection reset by peer]

==> Wait completed after 15 minutes 6 seconds

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso.windows-2022-amd64: error downloading ISO: [read tcp [2607:fb90:e200:ae63:d935:e425:b834:72dc]:60212->[2606:2800:11f:1cb7:261b:1f9c:2074:3c]:443: read: connection reset by peer]

==> Builds finished but no artifacts were created.

WinSxS folder cleanup fails on Windows-2022

Hello!

The Winsxs cleanup in optimize.ps1 fails on win2022 with:

Console:

    qemu.windows-2022-amd64: Error: 0x800f0806
    qemu.windows-2022-amd64:
    qemu.windows-2022-amd64: The operation could not be completed due to pending operations.

Dism.log:
dism.log

I ensured the TrustedInstaller, wuauserv and BITS services are all stopped.

I tried debugging myself but couldn't solve it, any help would be appreciated!

OpenSSH install error

d64-virtualbox: Downloading OpenSSH from https://www.mls-software.com/files/setupssh-7.5p1-1.exe...
d64-virtualbox: Installing OpenSSH...
d64-virtualbox: Installing the default vagrant insecure public key...
d64-virtualbox:
d64-virtualbox: ERROR: NewItemIOError
d64-virtualbox: ERROR: at <ScriptBlock>, C:\Windows\Temp\script.ps1: line 109 ERROR: at <ScriptBlock>, <No file>: line 1
d64-virtualbox:
d64-virtualbox: Sleeping for 60m to give you time to look around the virtual machine before self-destruction...
VirtualBox Version - 5.1.26r117224
PowerShell Version - 5.0
Packer Version - 1.0.4

I'll try to get some more info and potentially a fix in as soon as possible

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.