chef / bento

Packer templates for building minimal Vagrant baseboxes for multiple platforms

Home Page:http://chef.github.io/bento

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build failing with mkdir <unknown>

rufflabs opened this issue · comments

Version

202301.09.0

Environment

Windows 11 22H2, Hyper-V and VirtualBox 7.0

Scenario

Build Windows Server 2022 with either Hyper-V or VirtualBox

Steps to Reproduce

  1. packer build -only=virtualbox-iso.vm -var-file=os_pkrvars\windows\windows-2022-x86_64.pkrvars.hcl packer_templates\

Expected Result

Build a VM

Actual Result

Fails with error: Build 'virtualbox-iso.vm' errored after 22 seconds 627 milliseconds: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect. This happens whether using hyperv-iso or virtaulbox-iso.

c:\Build\bento>packer build -only=virtualbox-iso.vm -var-file=os_pkrvars\windows\windows-2022-x86_64.pkrvars.hcl packer_templates\
virtualbox-iso.vm: output will be in this color.

==> virtualbox-iso.vm: Retrieving Guest additions
==> virtualbox-iso.vm: Trying C:\Program Files\Oracle\VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: Trying file://C:/Program%20Files/Oracle/VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: file://C:/Program%20Files/Oracle/VirtualBox/VBoxGuestAdditions.iso => C:/Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: Retrieving ISO
==> virtualbox-iso.vm: Trying https://software-static.download.prss.microsoft.com/sg/download/888969d5-f34g-4e03-ac9d-1f9786c66749/SERVER_EVAL_x64FRE_en-us.iso
==> virtualbox-iso.vm: 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.vm: https://software-static.download.prss.microsoft.com/sg/download/888969d5-f34g-4e03-ac9d-1f9786c66749/SERVER_EVAL_x64FRE_en-us.iso?checksum=sha256%3A3e4fa6d8507b554856fc9ca6079cc402df11a8b79344871669f0251535255325 => c:\Build\bento\packer_cache\f1379c61c4705c2d66f46d271609fc75e967a5fe.iso
==> virtualbox-iso.vm: Deleting output directory...
Build 'virtualbox-iso.vm' errored after 22 seconds 627 milliseconds: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect.

==> Wait completed after 22 seconds 627 milliseconds

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso.vm: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect.

==> Builds finished but no artifacts were created.

c:\Build\bento>
c:\Build\bento>packer build -only=virtualbox-iso.vm -var-file=os_pkrvars\windows\windows-2022-x86_64.pkrvars.hcl packer_templates\
virtualbox-iso.vm: output will be in this color.

==> virtualbox-iso.vm: Retrieving Guest additions
==> virtualbox-iso.vm: Trying C:\Program Files\Oracle\VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: Trying file://C:/Program%20Files/Oracle/VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: file://C:/Program%20Files/Oracle/VirtualBox/VBoxGuestAdditions.iso => C:/Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: Retrieving ISO
==> virtualbox-iso.vm: Trying https://software-static.download.prss.microsoft.com/sg/download/888969d5-f34g-4e03-ac9d-1f9786c66749/SERVER_EVAL_x64FRE_en-us.iso
==> virtualbox-iso.vm: 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.vm: https://software-static.download.prss.microsoft.com/sg/download/888969d5-f34g-4e03-ac9d-1f9786c66749/SERVER_EVAL_x64FRE_en-us.iso?checksum=sha256%3A3e4fa6d8507b554856fc9ca6079cc402df11a8b79344871669f0251535255325 => c:\Build\bento\packer_cache\f1379c61c4705c2d66f46d271609fc75e967a5fe.iso
==> virtualbox-iso.vm: Deleting output directory...
Build 'virtualbox-iso.vm' errored after 22 seconds 627 milliseconds: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect.

==> Wait completed after 22 seconds 627 milliseconds

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso.vm: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect.

==> Builds finished but no artifacts were created.

c:\Build\bento>packer build -only=hyperv-iso.vm -var-file=os_pkrvars\windows\windows-2022-x86_64.pkrvars.hcl packer_templates\
hyperv-iso.vm: output will be in this color.

==> hyperv-iso.vm: Creating build directory...
==> hyperv-iso.vm: Deleting output directory...
==> hyperv-iso.vm: Deleting build directory...
Build 'hyperv-iso.vm' errored after 10 seconds 831 milliseconds: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect.

==> Wait completed after 10 seconds 831 milliseconds

==> Some builds didn't complete successfully and had errors:
--> hyperv-iso.vm: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect.

==> Builds finished but no artifacts were created.

c:\Build\bento>

can you try modifying this line https://github.com/chef/bento/blob/main/packer_templates/pkr-builder.pkr.hcl#L259 to point to the builds directory. I'm thinking windows may not like the ${path.root} variable.

Updated the path but it didn't change anything. I ran with -debug and got the following. In case it was permissions, I gave my user account full control over the c:\build directory. No change.

c:\Build\bento>packer build -debug -only=hyperv-iso.vm -var-file=os_pkrvars\windows\windows-2022-x86_64.pkrvars.hcl packer_templates\
Debug mode enabled. Builds will not be parallelized.
hyperv-iso.vm: output will be in this color.

==> hyperv-iso.vm: Creating build directory...
==> hyperv-iso.vm: Pausing after run of step 'StepCreateBuildDir'. Press enter to continue.
==> hyperv-iso.vm: Deleting output directory...
==> hyperv-iso.vm: Pausing before cleanup of step 'StepCreateBuildDir'. Press enter to continue.
==> hyperv-iso.vm: Deleting build directory...
Build 'hyperv-iso.vm' errored after 19 seconds 307 milliseconds: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect.

==> Wait completed after 19 seconds 307 milliseconds

==> Some builds didn't complete successfully and had errors:
--> hyperv-iso.vm: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect.

==> Builds finished but no artifacts were created.

c:\Build\bento>

Unfortunately I don't have a windows machine to test currently but on my mac for virtualbox It works fine for me. This makes me think it has something to do with the windows path.root variable. Unfortunately that -debug flag didn't give much more info.
Here's my output:

❯ packer build -only=virtualbox-iso.vm -var-file=os_pkrvars/windows/windows-2022-x86_64.pkrvars.hcl packer_templates
virtualbox-iso.vm: output will be in this color.

==> virtualbox-iso.vm: Retrieving Guest additions
==> virtualbox-iso.vm: Trying /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: Trying /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso => /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: Retrieving ISO
==> virtualbox-iso.vm: Trying https://software-static.download.prss.microsoft.com/sg/download/888969d5-f34g-4e03-ac9d-1f9786c66749/SERVER_EVAL_x64FRE_en-us.iso
==> virtualbox-iso.vm: 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.vm: SERVER_EVAL_x64FRE_en-us.iso 4.70 GiB / 4.70 GiB [====================================================================] 100.00% 1m11s
==> virtualbox-iso.vm: https://software-static.download.prss.microsoft.com/sg/download/888969d5-f34g-4e03-ac9d-1f9786c66749/SERVER_EVAL_x64FRE_en-us.iso?checksum=sha256%3A3e4fa6d8507b554856fc9ca6079cc402df11a8b79344871669f0251535255325 => /Users/corey.hemminger/.cache/packer/f1379c61c4705c2d66f46d271609fc75e967a5fe.iso
==> virtualbox-iso.vm: Creating floppy disk...
    virtualbox-iso.vm: Copying files flatly from floppy_files
    virtualbox-iso.vm: Copying file: packer_templates/win_answer_files/2022/Autounattend.xml
    virtualbox-iso.vm: Copying file: packer_templates/scripts/windows/base_setup.ps1
    virtualbox-iso.vm: Done copying files from floppy_files
    virtualbox-iso.vm: Collecting paths from floppy_dirs
    virtualbox-iso.vm: Resulting paths from floppy_dirs : []
    virtualbox-iso.vm: Done copying paths from floppy_dirs
    virtualbox-iso.vm: Copying files from floppy_content
    virtualbox-iso.vm: Done copying files from floppy_content
==> virtualbox-iso.vm: Starting HTTP server on port 8121
==> virtualbox-iso.vm: Creating virtual machine...
==> virtualbox-iso.vm: Creating hard drive <unknown>/windows-2022-amd64.vdi with size 65536 MiB...
==> virtualbox-iso.vm: Mounting ISOs...
    virtualbox-iso.vm: Mounting boot ISO...
    virtualbox-iso.vm: Mounting guest additions ISO...
==> virtualbox-iso.vm: Deleting any current floppy disk...
==> virtualbox-iso.vm: Attaching floppy disk...
==> virtualbox-iso.vm: Creating forwarded port mapping for communicator (SSH, WinRM, etc) (host port 4109)
==> virtualbox-iso.vm: Executing custom VBoxManage commands...
    virtualbox-iso.vm: Executing: modifyvm windows-2022-amd64 --audio none --nat-localhostreachable1 on
==> virtualbox-iso.vm: Starting the virtual machine...
    virtualbox-iso.vm: The VM will be run headless, without a GUI. If you want to
    virtualbox-iso.vm: view the screen of the VM, connect via VRDP without a password to
    virtualbox-iso.vm: rdp://127.0.0.1:5901
==> virtualbox-iso.vm: Waiting 1m0s for boot...
==> virtualbox-iso.vm: Typing the boot command...
==> virtualbox-iso.vm: Using WinRM communicator to connect: 127.0.0.1
==> virtualbox-iso.vm: Waiting for WinRM to become available...
    virtualbox-iso.vm: WinRM connected.
==> virtualbox-iso.vm: Connected to WinRM!
==> virtualbox-iso.vm: Uploading VirtualBox version info (7.0.4)
==> virtualbox-iso.vm: Provisioning with Powershell...
==> virtualbox-iso.vm: Provisioning with powershell script: packer_templates/scripts/windows/disable-windows-updates.ps1
==> virtualbox-iso.vm: Provisioning with powershell script: packer_templates/scripts/windows/disable-windows-defender.ps1

What version of packer are you using and did you do the packer init packer_templates to get the plugins?

I did do packer init packer_templates, just did it again to make sure and it had no output. I presume that meant nothing needed added? I am using packer version 1.8.5

How come your output doesn't have ==> virtualbox-iso.vm: Deleting output directory... which for me is followed by the mkdir error?

I just learned about setting PACKER_LOG=1 to get more info. Perhaps this is a packer issue and not a bento issue.

==> virtualbox-iso.vm: Deleting output directory...
2023/01/18 10:14:24 packer-plugin-virtualbox_v1.0.4_x5.0_windows_amd64.exe plugin: 2023/01/18 10:14:24 Error removing output dir: CreateFile <unknown>: The filename, directory name, or volume label syntax is incorrect.
2023/01/18 10:14:26 packer-plugin-virtualbox_v1.0.4_x5.0_windows_amd64.exe plugin: 2023/01/18 10:14:26 Error removing output dir: CreateFile <unknown>: The filename, directory name, or volume label syntax is incorrect.
2023/01/18 10:14:28 packer-plugin-virtualbox_v1.0.4_x5.0_windows_amd64.exe plugin: 2023/01/18 10:14:28 Error removing output dir: CreateFile <unknown>: The filename, directory name, or volume label syntax is incorrect.
2023/01/18 10:14:30 packer-plugin-virtualbox_v1.0.4_x5.0_windows_amd64.exe plugin: 2023/01/18 10:14:30 Error removing output dir: CreateFile <unknown>: The filename, directory name, or volume label syntax is incorrect.
2023/01/18 10:14:32 packer-plugin-virtualbox_v1.0.4_x5.0_windows_amd64.exe plugin: 2023/01/18 10:14:32 Error removing output dir: CreateFile <unknown>: The filename, directory name, or volume label syntax is incorrect.
2023/01/18 10:14:34 [INFO] (telemetry) ending virtualbox-iso.vm
==> Wait completed after 22 seconds 692 milliseconds
2023/01/18 10:14:34 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
Build 'virtualbox-iso.vm' errored after 22 seconds 692 milliseconds: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect.
2023/01/18 10:14:34 machine readable: virtualbox-iso.vm,error []string{"mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect."}
==> Builds finished but no artifacts were created.
2023/01/18 10:14:34 [INFO] (telemetry) Finalizing.

==> Wait completed after 22 seconds 692 milliseconds

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso.vm: mkdir <unknown>: The filename, directory name, or volume label syntax is incorrect.

==> Builds finished but no artifacts were created.

I'm also running packer v1.8.5. I just found the issue. When I'd start a build having finder(explorer for windows) open I noticed in the root of bento, which was my working directory when running packer command , a folder called was created as the vm directory. Researching how to fix that found that it's driven by the source output_directory option. It didn't like the path.root and source.provider variables in the path string. I have a fix for that in this pr #1465.

Great news!

I'm still pretty new to git, how can I grab that pr to try?

When in terminal in the bento directory run git pull && git checkout fix_ubuntu2210. If you have any changes you'll need to either revert them or run git stash before it'll let you switch branches.

That appears to have worked! Thanks for hunting this down and figuring it out!

thanks for confirming the fix for me.