VMware Cloud Community
TspTechie
Contributor
Contributor
Jump to solution

Using ovftool to import VMs during kickstart fails

Using kickstart to automate ESXi host installation. All commands in the ks.cfg file are executed and the host installs successfully. However the commands specified in the ks.cfg file for importing VMs via OVAs and ovftool are either failing or not executing. Ovftool is version 4.3, extracted from tarball to datastore1/vmware-ovftool folder during kickstart.

The same command that doesn't work in ks.cfg works fine in SSH and ESXi shell after host installation finishes:

sh ./vmfs/volumes/datastore1/vmware-ovftool/ovftool -dm=thin -ds=datastore1 --noSSLVerify "/vmfs/volumes/datastore1/OVA/VM1.ova" "vi://root:P@ssword@localhost"

The /var/log/weasel.log file does not exist on the host after kickstart installation. Is there another log available that records errors from failed commands executed in ks.cfg file I can check to help troubleshoot this issue? Or can I enable some type of logging within the kickstart file (ks.cfg)?

ESXi version is 6.7U1.

Thanks in advance for any assistance you may be able to provide.

1 Solution

Accepted Solutions
thehack904
Contributor
Contributor
Jump to solution

After 2 1/2 weeks of trying to get this to work I believe I figured out how to do this.  It has to do with the environmental variables that ESXi uses.  The variables are different between root running a script and the command line shell variables.  If you use the env or set command you should see a list of variables.

HISTFILE='/.ash_history'

HOME='/'

HOSTNAME='esxi_host.local.net'

IFS=' '

LANG='en_US.UTF-8'

LC_ALL='en_US.UTF-8'

LINENO=''

LOGNAME='root'

MAIL='/var/mail/root'

OPTIND='1'

PATH='/bin:/sbin'

PPID='2099700'

PS1='[root@\h:\w] '

PS2='> '

PS4='+ '

PWD='/'

SHELL='/bin/sh'

SHLVL='1'

SSH_TTY='/dev/char/pty/t0'

TERM='xterm-256color'

TERMINFO='/usr/share/terminfo'

TMOUT='0'

USER='root'

VI_USERNAME='root'

_='ls'

secureBoot='0'

I went in and took those same variables and put export before each one.  I then placed all of them right after my #!/bin/sh and it worked like a charm.  I haven't taken the time to go back to figure out which one does the trick.  May do that later by finding out the root environmental variables and diff them with these to see the difference.

Also don't forget to change #!/bin/bash to #!/bin/sh ( https://www.virtuallyghetto.com/2012/05/how-to-deploy-ovfova-in-esxi-shell.html )

And a word of caution...don't copy and paste my above settings.  I had to modify them to show up correctly on the webpage.

Hope this helps.

View solution in original post

9 Replies
TspTechie
Contributor
Contributor
Jump to solution

UPDATE: Found this older article: VMware Knowledge Base and noticed the statement 'Caution: Do not reboot the ESXi host after the install fails, or the weasel.log file is lost. Weasel is VMware’s boot loader for ESX/ESXi'.

Still, the weasel.log file proved to be no help because of course it only logs installation errors, not post-installation (%firstboot) Busybox command errors. Since I'm grasping at straws here I thought I'd check anyway.

So I still can't find a log that records the commands in KS.CFG as they are executed during %firstboot and the possible error output of each. Thought firstboot.log or kickstart.log may be likely suspects to contain the info I need, but alas not so much. I even tried adding '>> /var/log/custom_install.log' to the end of a couple of random commands in the KS.CFG, including one of the lines that attempts the OVA import using the ovftool. But no luck there either.

After the post-installation reboot and kickstart completion, I SSH'd in and grepped through the entire /var/log folder looking for any hint of the execution of specific commands in my KS.CFG. Only esxi_install.log was found, and its content was the same as weasel.log; just validation confirmation.

Google searches have come up empty. No replies yet to my original post last week. Any help? Hard to imagine no one else has come across this before.

Reply
0 Kudos
ctbower
Contributor
Contributor
Jump to solution

Hi,

Did you ever find the solution to this problem? I am running into the same thing...

Reply
0 Kudos
TspTechie
Contributor
Contributor
Jump to solution

Unfortunately not. Project has been in idle state since my last post. 132 views and you're the first to post a reply in almost a month... the silence is deafening :smileyconfused:...

Reply
0 Kudos
ctbower
Contributor
Contributor
Jump to solution

i know what you mean.

Strange it doesn't work from kickstart file but it does on command line via SSH.

I am trying to build up this kick start file to deploy about 100 vSphere instances that are all built the same.

Reply
0 Kudos
thehack904
Contributor
Contributor
Jump to solution

After 2 1/2 weeks of trying to get this to work I believe I figured out how to do this.  It has to do with the environmental variables that ESXi uses.  The variables are different between root running a script and the command line shell variables.  If you use the env or set command you should see a list of variables.

HISTFILE='/.ash_history'

HOME='/'

HOSTNAME='esxi_host.local.net'

IFS=' '

LANG='en_US.UTF-8'

LC_ALL='en_US.UTF-8'

LINENO=''

LOGNAME='root'

MAIL='/var/mail/root'

OPTIND='1'

PATH='/bin:/sbin'

PPID='2099700'

PS1='[root@\h:\w] '

PS2='> '

PS4='+ '

PWD='/'

SHELL='/bin/sh'

SHLVL='1'

SSH_TTY='/dev/char/pty/t0'

TERM='xterm-256color'

TERMINFO='/usr/share/terminfo'

TMOUT='0'

USER='root'

VI_USERNAME='root'

_='ls'

secureBoot='0'

I went in and took those same variables and put export before each one.  I then placed all of them right after my #!/bin/sh and it worked like a charm.  I haven't taken the time to go back to figure out which one does the trick.  May do that later by finding out the root environmental variables and diff them with these to see the difference.

Also don't forget to change #!/bin/bash to #!/bin/sh ( https://www.virtuallyghetto.com/2012/05/how-to-deploy-ovfova-in-esxi-shell.html )

And a word of caution...don't copy and paste my above settings.  I had to modify them to show up correctly on the webpage.

Hope this helps.

ctbower
Contributor
Contributor
Jump to solution

I finally came back to work on this and found your reply.

Here's my env output

[root@localhost:~] env

USER=root

MAIL=/var/mail/root

SSH_CLIENT=192.168.130.76 61795 22

SHLVL=1

HOME=/

TERMINFO=/usr/share/terminfo

SSH_TTY=/dev/char/pty/t0

PS1=[root@\h:\w]

LOGNAME=root

VI_USERNAME=root

TERM=xterm-256color

PATH=/bin:/sbin

LANG=en_US.UTF-8

SHELL=/bin/sh

LC_ALL=en_US.UTF-8

PWD=/

SSH_CONNECTION=192.168.130.76 61795 192.168.130.40 22

TMOUT=0

And here is the ovftool I'm using on my ESXi host. Yes, I know I didn't put all the variables in there, but I didn't think the SSH variables would make a difference.

#!/bin/sh

# ------------------------

# Start Script for ovftool

# ------------------------

# resolve links - $0 may be a softlink

export PS1=[root@\h:\w]

export PS2='> '

export PS4='+'

export TMOUT=0

export HOME=/

export SHLVL=1

export PATH=/bin:/sbin

export SHELL=/bin/sh

export USER=root

export PWD=/

export LOGNAME=root

export LINENO=''

export TERMINFO=/usr/share/terminfo

PRG="$0"

if [ -L "$PRG" ]; then

   PRG=`readlink "$PRG"`

fi

PRGDIR=`dirname "$PRG"`

OVFTOOL_BIN="$PRGDIR"/ovftool.bin

export LD_LIBRARY_PATH="$PRGDIR":"$LD_LIBRARY_PATH"

if [ ! -e "$OVFTOOL_BIN" ]; then

   echo "Cannot find $OVFTOOL_BIN"

   exit 1

fi

exec "$OVFTOOL_BIN" "$@"

exit $?

Did you come across the variables that would be needed to get this to run?

Perhaps I have my KS.cfg file out of sorts... :smileyconfused:

Reply
0 Kudos
ctbower
Contributor
Contributor
Jump to solution

Ok after many many tries, finally got this working.

Copied all the environment variables that were preset using the set command as stated above. Took out the SSH since they weren't needed and that did the trick. Thanks for the tip!

Reply
0 Kudos
thehack904
Contributor
Contributor
Jump to solution

Just saw your reply.  Glad you were able to get it to work.  I find it interesting that removing the SSH variable made it work.

Reply
0 Kudos
TspTechie
Contributor
Contributor
Jump to solution

After a long stretch wrestling higher priority distractions, I was finally able to get back to this. Big thanks to both ctbower​ and thehack904​ for going the distance on this. Querying the host for, and adding the resultant environment variables in the ovftool script file did the trick. I'm now pumping out ESXi hosts at record pace, fully populated with VMs for our standard system deployment.