Discussion:
[Fab-user] Running fabric on VMware ESXi
Carlos García
2015-02-04 09:18:11 UTC
Permalink
Hi list,

I was trying to execute some commands on an ESX server, but I'm having some
problems.

ESX has a custom Linux, it lacks of sudo, bash among many other things.

Anyway, I just want to run a simple ls so the code I'm trying to run is:



@task
def esx_cmd( command ):
env.shell = '/bin/sh'
return run(command)
fab esx_cmd:"ls" -H host
And the output:

[host] Executing task 'run_cmd'
[host] run: ls
[host] Login password for 'user':
[host] out: /bin/sh: can't open 'ls'
[host] out:


Fatal error: run() received nonzero return code 2 while executing!

Requested: ls
Executed: /bin/sh "ls"

Aborting.
Disconnecting from host... done.



If I run the same command in an interactive SSH session on that host:

The ESXi Shell can be disabled by an administrative user. See the
vSphere Security documentation for more information.
~ # env
SSH_CLIENT=X.X.X.X 50909 22
MAIL=/var/mail/user
USER=user
TERMINFO=/usr/share/terminfo
HOME=/
SSH_TTY=/dev/char/pty/t0
VI_USERNAME=user
LOGNAME=user
TERM=xterm
PATH=/bin:/sbin
LANG=en_US.UTF-8
SHELL=/bin/sh
PWD=/
LC_ALL=en_US.UTF-8
SSH_CONNECTION=X.X.X.X 50909 X.X.X.X 22
TMOUT=0
~ # ls
VIB bootbank etc local.tgz opt
sbin tardisks usr vmimages
altbootbank bootpart.gz lib locker proc
scratch tardisks.noauto var vmupgrade
bin dev lib64 mbr
productLocker store tmp vmfs

~ #


What I'm doing wrong??


Thanks in advance
Carlos García
2015-02-04 10:27:10 UTC
Permalink
Hi Wawrzek,

I have included the env variables (stripped in your mail?). The PATH is
PATH=/bin:/sbin

Anyway, executing via fabric esx_run:"/bin/ls" throws a weirder message.


[host] out: /bin/ls: line 1: syntax error: unexpected "("
[host] out:


Fatal error: run() received nonzero return code 2 while executing!

Requested: /bin/ls
Executed: /bin/sh "/bin/ls"

Aborting.


Fabric is executing /bin/sh /bin/ls, so it looks like it' trying to run ls
as a shell script. So I changed my code and run is now called with shell =
False

run( command, shell = False)


And now it's working!

Thanks anyway
On 4 February 2015 at 09:18, Carlos García
Post by Carlos García
Hi list,
I was trying to execute some commands on an ESX server, but I'm having
some
Post by Carlos García
problems.
ESX has a custom Linux, it lacks of sudo, bash among many other things.
[...]
Post by Carlos García
[host] Executing task 'run_cmd'
[host] run: ls
[host] out: /bin/sh: can't open 'ls'
[...]
Post by Carlos García
What I'm doing wrong??
Lack of PATH environment or rather '/bin' in it.
Have you try to run /bin/ls instead of ls?
Wawrzek
--
Dr Wawrzyniec Niewodniczański or Wawrzek for short
PhD in Quantum Chemistry & MSc in Molecular Engineering
Linux User #177124
--
Carlos García
Director de Operaciones
Tel. 695 624 167 - 902 620 100
www.stoneworksolutions.net

AVISO DE CONFIDENCIALIDAD
Tanto este mensaje como todos los posibles documentos adjuntos al mismo son
confidenciales y están dirigidos exclusivamente a los destinatarios de los
mismos. Por favor, si Ud no es uno de dichos destinatarios, notifíquenos
este hecho y elimine el mensaje de su sistema. Queda prohibida la copia,
difusión o revelación de su contenido a terceros sin el previo
consentimiento por escrito del remitente. En caso contrario, vulnerarán la
legislación vigente
Loading...