hashicorp / packer-plugin-vmware

Packer plugin for VMware Builder
https://www.packer.io/docs/builders/vmware
Mozilla Public License 2.0
47 stars 41 forks source link

vmware player builds don't work on currently supported versions #12

Closed ghost closed 1 year ago

ghost commented 3 years ago

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


the vmware player builder needs a couple of tools, including vmrun. According to this thread, vmrun was deprecated in version 12. It may be possible to get it running with VIX api libraries.

We should either figure out how to get builds to run with the currently available player, or refuse to run with a useful error message if the wrong version of player is installed.

See:

1102

4503

and reverted commit c5ec92c88bb154bd317aec5b81ba6cf9e4dff9c4

rgarrigue commented 3 years ago

A fix or workaround is still needed out there

arttkach commented 2 years ago

Did this get any traction? I tried to build an image using VMware-Player-Full-16.2.3-19376536.x86_64.bundle but what I get is: zedge@master:~/packer$ packer build img.pkr.hcl vmware-iso.ubuntu-packer: output will be in this color.

Build 'vmware-iso.ubuntu-packer' errored after 941 microseconds: Failed creating VMware driver: Unable to initialize any driver for this platform. The errors from each driver are shown below. Please fix at least one driver to continue:

==> Wait completed after 980 microseconds

==> Some builds didn't complete successfully and had errors: --> vmware-iso.ubuntu-packer: Failed creating VMware driver: Unable to initialize any driver for this platform. The errors from each driver are shown below. Please fix at least one driver to continue:

==> Builds finished but no artifacts were created.

Lixeas commented 1 year ago

Hello @arttkach,

I also entered the problem. I spent several days before solving it. For my part I have a linux machine Ubuntu 20.04.6 LTS (Focal Fossa) To be able to solve the problem go to the link below: https://communities.vmware.com/t5/VMware-Workstation-Player/VMWARE-VIX-1-17-Error-at-installing/m-p/2825004/highlight/true#M36206

First, uninstall VMware Player. Then launch the installation of VMware-VIX first then reinstall VMware Player. In my case, it worked. I use VMware Workstation Player 17 and VMware VIX 1.17.

And then just follow the Packer instructions: https://developer.hashicorp.com/packer/plugins/builders/vmware#vmware-workstation-player-on-linux

kbcz1989 commented 1 year ago

This is how I got it to work on Ubuntu 22.04, but should work on others also:

# install Workstation 17.0.2
wget -c -P /tmp --content-disposition --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0" https://www.vmware.com/go/getworkstation-linux
chmod u+x /tmp/VMware-Workstation-Full-17.0.2-21581411.x86_64.bundle
sudo /tmp/VMware-Workstation-Full-17.0.2-21581411.x86_64.bundle --console --eulas-agreed

# make backup of vix files
tar -C /usr/lib/vmware-vix -czvf /tmp/vix-patch-17.0.2.tar.gz ./Workstation-17.0.0

# uninstall Workstation
sudo vmware-installer --uninstall-product=vmware-workstation

# install VIX 1.17.0
wget -c -P /tmp https://download3.vmware.com/software/player/file/VMware-VIX-1.17.0-6661328.x86_64.bundle
chmod u+x /tmp/VMware-VIX-1.17.0-6661328.x86_64.bundle
sudo /tmp/VMware-VIX-1.17.0-6661328.x86_64.bundle --console --eulas-agreed

# install Player 17.0.2
wget -c -P /tmp --content-disposition --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0" https://www.vmware.com/go/getplayer-linux
chmod u+x /tmp/VMware-Player-Full-17.0.2-21581411.x86_64.bundle
sudo /tmp/VMware-Player-Full-17.0.2-21581411.x86_64.bundle --console --eulas-agreed

# restore vix files
tar -xzvf /tmp/vix-patch-17.0.2.tar.gz -C /usr/lib/vmware-vix/

# set vixwrapper
sudo sed -i -E 's/(player\s+19\s+vmdb\s+)e\.x\.p\s+Workstation-14.0.0/\117.0.2 Workstation-17.0.0/' /usr/lib/vmware-vix/vixwrapper-config.txt

If Secure Boot is used, drivers needs to be signed: https://kb.vmware.com/s/article/2146460

tenthirtyam commented 1 year ago

Resolutions:

erkanerol commented 1 year ago

I hit this issue and couldn't manage to install the tools.

I used Ubuntu 22.04.3 LTS and followed the steps here https://github.com/hashicorp/packer-plugin-vmware/issues/12#issuecomment-1633043996

It failed in this step:

> sudo /tmp/VMware-VIX-1.17.0-6661328.x86_64.bundle --console --eulas-agreed
Extracting VMware Installer...done.
User interface initialization failed.  Exiting.  Check the log for details.

The logs are as below:

> cat /tmp/vmware-root/vmware-vmis-12169.log
2023-09-13T08:55:03.115Z| host-139901634823296| I125: [msg.dictionary.load.openFailed] Cannot open file "/root/.vmware/config": No such file or directory.
2023-09-13T08:55:03.115Z| host-139901634823296| I125: PREF Optional preferences file not found at /root/.vmware/config. Using default values.
2023-09-13T08:55:03.115Z| host-139901634823296| I125: DictionaryLoad: Cannot open file "/root/.vmware/preferences": No such file or directory.
2023-09-13T08:55:03.115Z| host-139901634823296| I125: [msg.dictionary.load.openFailed] Cannot open file "/root/.vmware/preferences": No such file or directory.
2023-09-13T08:55:03.115Z| host-139901634823296| I125: PREF Optional preferences file not found at /root/.vmware/preferences. Using default values.

@kbcz1989 Did you apply another thing other than the steps you shared?

kbcz1989 commented 1 year ago

@erkanerol Hello. Are you sure you're looking at the right logs? Check /var/log/vmware-installer.

Try this:

sudo ln -s /usr/lib/x86_64-linux-gnu/libncursesw.so.6.3 /usr/lib/x86_64-linux-gnu/libncursesw.so.5
sudo ldconfig

and run VIX installation again.

erkanerol commented 1 year ago

@kbcz1989 Thanks a lot for helping. You are right. I checked the logs and it is because of libncursesw library. Running this in the beginning worked.

sudo apt-get update
sudo apt-get install libncurses5

sudo ln -s /usr/lib/x86_64-linux-gnu/libncursesw.so.6.3 /usr/lib/x86_64-linux-gnu/libncursesw.so.5
sudo ldconfig
erkanerol commented 1 year ago

@kbcz1989 Are you able to start a VM after installing tools? I hit this error:

vmrun -T player start flatcar_production_vmware.vmx nogui
Error: Unknown error

Related https://github.com/hashicorp/packer-plugin-vmware/issues/146#issuecomment-1717670335

kbcz1989 commented 1 year ago

Check the logs in /tmp/vmware-/vmware-vmx-.log

erkanerol commented 1 year ago

@kbcz1989 Thank you for pointing out the log file. I noticed the issue is the one you pointed out above related to Secure Boot. However, the steps in the VMware article don't work for me. I am using a VM in vSphere. That can be the reason. Are you using bare metal?

I saw this line in the article.

During the installation, if the host provides the proper kernel headers and gcc, these two modules will be built silently. 

and then tried installing gcc before vmware tools. The vmmon issue disappeared but hit another issue.

Here is my whole installation script

# install dependencies 
sudo apt-get update
sudo apt-get install -y libncurses5

sudo ln -s /usr/lib/x86_64-linux-gnu/libncursesw.so.6.3 /usr/lib/x86_64-linux-gnu/libncursesw.so.5
sudo ldconfig

export NEEDRESTART_MODE=a
apt install -y make
apt install -y gcc
apt install -y libxi6 libgconf-2-4
apt install -y libxinerama-dev
apt install -y libxtst-dev
apt install -y libxcursor-dev

# install Workstation 17.0.2
wget -c -P /tmp --content-disposition --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0" https://www.vmware.com/go/getworkstation-linux
chmod u+x /tmp/VMware-Workstation-Full-17.0.2-21581411.x86_64.bundle
sudo /tmp/VMware-Workstation-Full-17.0.2-21581411.x86_64.bundle --console --eulas-agreed --required

# make backup of vix files
tar -C /usr/lib/vmware-vix -czvf /tmp/vix-patch-17.0.2.tar.gz ./Workstation-17.0.0

# uninstall Workstation
sudo vmware-installer --uninstall-product=vmware-workstation --required

# install VIX 1.17.0
wget -c -P /tmp https://download3.vmware.com/software/player/file/VMware-VIX-1.17.0-6661328.x86_64.bundle
chmod u+x /tmp/VMware-VIX-1.17.0-6661328.x86_64.bundle
sudo /tmp/VMware-VIX-1.17.0-6661328.x86_64.bundle --console --eulas-agreed --required

# install Player 17.0.2
wget -c -P /tmp --content-disposition --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0" https://www.vmware.com/go/getplayer-linux
chmod u+x /tmp/VMware-Player-Full-17.0.2-21581411.x86_64.bundle
sudo /tmp/VMware-Player-Full-17.0.2-21581411.x86_64.bundle --console --eulas-agreed --required

# restore vix files
tar -xzvf /tmp/vix-patch-17.0.2.tar.gz -C /usr/lib/vmware-vix/

# set vixwrapper
sudo sed -i -E 's/(player\s+19\s+vmdb\s+)e\.x\.p\s+Workstation-14.0.0/\117.0.2 Workstation-17.0.0/' /usr/lib/vmware-vix/vixwrapper-config.txt
sudo sed -i -E 's/(player\s+19\s+vmdb\s+)14\.0\.0\s+Workstation-14.0.0/\117.0.2 Workstation-14.0.0/' /usr/lib/vmware-vix/vixwrapper-config.txt

# test steps
cd /tmp
wget https://stable.release.flatcar-linux.net/amd64-usr/current/flatcar_production_vmware.vmx
vmrun -T player start flatcar_production_vmware.vmx nogui

and here is the last error:

 2023-09-18T14:53:12.460Z In(05) vmx VmdbPipeStreamsOvlError Couldn't read: OVL_STATUS_EOF (remote disconnect)

Honestly, I plan to give up trying to make this work. I will try using a remote vSphere to build images.

kbcz1989 commented 1 year ago

Hey @erkanerol, don't give up, you're so close :)

Your script suggests that you're downloading only one *.vmx file, that is not enough to run the VM. Looking at my history, I think I did something like this:

wget https://virtuallymikebrown.files.wordpress.com/2012/02/dsl-4-4-10.doc
mv dsl-4-4-10.doc dsl-4-4-10.tgz
tar -xvpf dsl-4-4-10.ova.tgz
ovftool ./DSL-4.4.10.ovf DSL-4.4.10.vmx
vmrun -T player start DSL-4.4.10.vmx nogui

looks awful, cannot recall the reasoning, probably upstream README.

What did you mean by "vsphere"? This is for building on local vmplayer/workstation, no vsphere involved.

erkanerol commented 1 year ago

@kbcz1989 Thanks for the motivation :)

I tried your steps but they failed after fixing the tar command.

ovftool ./DSL-4.4.10.ovf DSL-4.4.10.vmx
Opening OVF source: ./DSL-4.4.10.ovf
The manifest validates
Opening VMX target: DSL-4.4.10.vmx
Error: File already exists: ./DSL-4.4.10-disk1.vmdk
Completed with errors

I changed my test steps to download vmdk too.

apt install -y bzip2
cd /tmp
wget https://stable.release.flatcar-linux.net/amd64-usr/current/flatcar_production_vmware_image.vmdk.bz2
wget https://stable.release.flatcar-linux.net/amd64-usr/current/flatcar_production_vmware.vmx
bzip2 -d flatcar_production_vmware_image.vmdk.bz2
vmrun -T player start flatcar_production_vmware.vmx nogui

Now, I am receiving this error:

2023-09-19T15:19:33.136Z In(05) vmx Vix: [mainDispatch.c:4251]: Error VIX_E_FAIL in VMAutomation_ReportPowerOpFinished(): Unknown error

vix logs are as below:

2023-09-19T15:19:33.145Z In(05) vix-poll FoundryVMDBPowerOpCallback: VMDB reports power op failed for VM /tmp/test/flatcar_production_vmware.vmx with error msg = "This host does not support Intel VT-x.
2023-09-19T15:19:33.145Z In(05)+ vix-poll This host appears to be running in a virtual machine with VHV disabled. Ensure that VHV is enabled in the virtual machine configuration file.
2023-09-19T15:19:33.145Z In(05)+ vix-poll Module 'MonitorMode' power on failed.
2023-09-19T15:19:33.145Z In(05)+ vix-poll Failed to start the virtual machine.
2023-09-19T15:19:33.145Z In(05)+ vix-poll " and error code -57.
2023-09-19T15:19:33.145Z In(05) vix-poll Vix: [foundryVMMsgPost.c:1360]: Error VIX_E_FAIL in FoundryVMGetMsgPostError(): Unknown error
2023-09-19T15:19:33.145Z In(05) vix-poll Vix_TranslateMsgPostError: No translation found for error message "This host does not support Intel VT-x.
2023-09-19T15:19:33.145Z In(05)+ vix-poll This host appears to be running in a virtual machine with VHV disabled. Ensure that VHV is enabled in the virtual machine configuration file.
2023-09-19T15:19:33.145Z In(05)+ vix-poll Module 'MonitorMode' power on failed.
2023-09-19T15:19:33.145Z In(05)+ vix-poll Failed to start the virtual machine.

Actually, it points out my concerns. I use a Ubuntu VM in vSphere to run all these commands. It is not bare metal. That may lead to the difference between my setup and your setup.

Background: I am trying to bake node images for Kubernetes clusters. There is a special project for this purpose: https://github.com/kubernetes-sigs/image-builder It uses packer and some builders under the hood. I hit this issue while trying to use that project. The project supports two ways to build images: local uses vmware-iso and vsphere uses vsphere-iso . I plan to stop trying vmware-iso and to use vsphere-iso instead.

Thanks a lot for helping me.

For the maintainers of this repo and vmware-iso plugin, it will be awesome if you maintain a doc about how to install dependencies for the builder. Otherwise, as you can see, users suffer from dependency issues a lot.

erkanerol commented 1 year ago

Update: I found this https://communities.vmware.com/t5/VMware-Workstation-Pro/Nested-VM-s/td-p/2303905 and applied to my host VM. It worked now. Wow🎉🎉🎉

kbcz1989 commented 12 months ago

Great news! Yes, nested virtualization is required. We now have enough info to compile the final document. I will try to test it on fresh install when I get the chance.