hashicorp / packer-plugin-vsphere

Packer plugin for VMware vSphere Builder
https://www.packer.io/docs/builders/vsphere
Mozilla Public License 2.0
97 stars 94 forks source link

`vsphere-iso`: packer-tmp-created-floppy.flp - contains corrupted files when "too many" files are added #8

Closed ghost closed 1 year ago

ghost commented 3 years ago

This issue was originally opened by @jason-azze as hashicorp/packer#9998. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

A vsphere-iso build for Windows VMs that used to work began failing after I added a few more provisioning scripts to it. The specific symptom I encountered was that the Windows setup wizard began to complain that it could not find Autounattend.xml (which is the "answer file" for a quiet Windows installation). I eventually determined that the copy of Autounattend.xml on the packer-tmp-created-floppy.flp was corrupt, as were several other files. So Windows was telling the truth when it would hang during what was supposed to be an unattended setup.

I began to suspect that the provisioning scripts that I had added to my build were at fault because that was the only change I had made. I suspected that something in the file names was causing the data stream to be corrupted during floppy creation, or perhaps I had a weird, unprintable unicode character in my script from a bad copy-paste out of Slack! While I played around with this idea, I began shortening the file names of my new scripts. I eventually discovered (after a generous application of profanity) that a combination of shortening file names and deleting an unneeded file resulted in an uncorrupted flp file and the build was able to proceed. (Note, I checked to be sure was not exceeding the size of a typical floppy.)

So, I think I'm running into something like "too many arguments" for whatever code rolls up the files into the packer-tmp-created-floppy.flp, or perhaps too many total characters. ?

Reproduction Steps

Run a build with more than this many characters:

ls setup |wc -m
1670

or perhaps this many files:

ls setup |wc -l
69

in your packer-tmp-created-floppy.flp

My build failed because Autounattend.xml happened to be corrupted during the floppy image creation. YMMV.

To prove this to myself, I snagged the temporary .flp file that Packer creates during the build. In my case, the file appears in /tmp. I cracked the file open with Archive Manager (it's some kind of zip) and tried opening files one by one. Several were corrupted, including Autounattend.xml.

Packer version

packer version
Packer v1.6.2

I tried with 1.6.1 and 1.6.0 as well. Same problem.

Simplified Packer Buildfile

In the reproduction steps above I show that I have 69 files in my setup directory (which works, add more to repro the bug). This is what I use setup for (roughly):

  "provisioners": [
    {
      "type": "shell-local",
      "scripts": [
       "setup/test-ssh-dir-get.sh"
      ]
    },
    {
      "type": "windows-shell",
      "inline": ["dir c:\\"]
    },
    {
      "type": "powershell",
      "scripts": [
        "setup/123.ps1"
      ]
    },
    {
      "type": "windows-shell",
      "valid_exit_codes": [0, 3010, 3221227356],
      "scripts": [
        "setup/firewall-off.cmd",
        "setup/network-location-awareness-off.cmd",
        "setup/power-setting.cmd",
        "setup/rdp-enable.cmd",
        "setup/test-user-password-expire-never.cmd",
        "setup/updates-stop-them.cmd",
        "setup/installers-dir-make.cmd",
        "setup/tools-dir-make.cmd",
        "setup/7zip-install.cmd",
        "setup/glorp.cmd",
        "setup/crash-dump-tune.cmd",
        "setup/domain-suffix-set.cmd",
        "setup/file-extensions-and-hidden-files-show.cmd",
        "setup/indexing-turn-off.cmd",
        "setup/timezone-set-local.cmd",
        "setup/windows-annoyances-disable.cmd",
        "setup/windows-defender-disable.cmd"
      ]
    },
    {
      "type": "file",
      "source": "files/.ssh",
      "destination": "C:\\home\\test\\"
    },
    {
      "type": "file",
      "source": "setup/ssh-fix-owner-mode.sh",
      "destination": "C:\\Windows\\Temp\\"
    },
    {
      "type": "file",
      "source": "files/environment",
      "destination": "C:\\Windows\\Temp\\"
    },
    {
      "type": "file",
      "source": "files/sshd_config",
      "destination": "C:\\Windows\\Temp\\"
    },
    {
      "type": "file",
      "source": "setup/ssh-copy-config-files.sh",
      "destination": "C:\\Windows\\Temp\\"
    },
    {
      "type": "powershell",
      "scripts": [
        "setup/cygwin-sshd-config.ps1",
        "setup/pagefile-size.ps1",
        "setup/bginfo-shortcut.ps1",
        "setup/windows-annoyances-and-tweaks.ps1",
        "setup/path-length-longer.ps1"
      ]
    },
    {
      "type": "windows-shell",
      "valid_exit_codes": [0, 3010, 3221549136, 3221227356],
      "scripts": [
        "setup/jenkinsapi-install.cmd",
        "setup/cygwin-setfacl-fix.cmd",
        "setup/drive-map-cleanup.cmd",
        "setup/product-key-fix.cmd",
        "setup/CHANGEME-zero-free-space.cmd"
      ]
    }
  ]
}

Notice the files called 123 and glorp? That's me shortening descriptive names.

Operating system and Environment details

cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"

Log Fragments and crash.log files

PACKER_LOG=1 gives lots of nice detail, but there's no error logged when the floppy is created.

tenthirtyam commented 1 year ago

No reactions or comments in over 3 years.

Closing based on https://github.com/hashicorp/packer/issues/9998#issuecomment-718248167.