salt icon indicating copy to clipboard operation
salt copied to clipboard

salt-ssh 2015.2.0rc2 fails when target doesn't have lspci available

Open philipsd6 opened this issue 11 years ago • 25 comments

[root@master salt]# salt-ssh -W --pcre server01 -r "which lspci"
server01:
    ----------
    retcode:
        1
    stderr:
        which: no lspci in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin)
    stdout:

[root@master salt]# salt-ssh -W --pcre server01 cmd.run hostname
server01:
    ----------
    retcode:
        0
    stderr:
        Traceback (most recent call last):
        ....snip....
          File "/tmp/.ba6ee7/salt/grains/core.py", line 164, in _linux_gpu_data
            lspci_out = __salt__['cmd.run']('lspci -vmm')
          File "/tmp/.ba6ee7/salt/modules/cmdmod.py", line 525, in _run_quiet
            saltenv=saltenv)['stdout']
          File "/tmp/.ba6ee7/salt/modules/cmdmod.py", line 392, in _run
            .format(cmd, kwargs, exc)
        salt.exceptions.CommandExecutionError: Unable to run command ['lspci', '-vmm'] with the context {'with_communicate': True, 'shell': False, 'env': {*snipped*}, 'stdout': -1, 'close_fds': True, 'stdin': None, 'stderr': -2, 'cwd': '/home/normaluser'}, reason: [Errno 2] No such file or directory
    stdout:

This was supposed to be fixed two years ago in #5627?

philipsd6 avatar May 04 '15 19:05 philipsd6

@philipsd6, thanks for the report. That is strange that it would get past the salt.utils.which('lspci') statement. Will you paste the output of salt-ssh -l trace -W --pcre server01 cmd.run hostname? Thanks.

jfindlay avatar May 06 '15 00:05 jfindlay

OK, heavily redacted, but still long:

[root@SALT01057 salt]# salt-ssh -l trace --pcre server01 cmd.run hostname
[INFO    ] Loading Saltfile from '/etc/salt/Saltfile'
[DEBUG   ] Reading configuration from /etc/salt/Saltfile
[DEBUG   ] Reading configuration from /etc/salt/master
[DEBUG   ] Including configuration from '/etc/salt/master.d/99-file-roots.conf'
[DEBUG   ] Reading configuration from /etc/salt/master.d/99-file-roots.conf
[DEBUG   ] Including configuration from '/etc/salt/master.d/99-gpu_grains.conf'
[DEBUG   ] Reading configuration from /etc/salt/master.d/99-gpu_grains.conf
[DEBUG   ] Including configuration from '/etc/salt/master.d/99-output-mode.conf'
[DEBUG   ] Reading configuration from /etc/salt/master.d/99-output-mode.conf
[DEBUG   ] Including configuration from '/etc/salt/master.d/99-pillar-roots.conf'
[DEBUG   ] Reading configuration from /etc/salt/master.d/99-pillar-roots.conf
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: salt01057
[TRACE   ] None of the required configuration sections, 'logstash_udp_handler' and 'logstash_zmq_handler', were found the in the configuration. Not loading the Logstash logging handlers module.
[TRACE   ] The required configuration section, 'fluent_handler', was not found the in the configuration. Not loading the fluent logging handlers module.
[DEBUG   ] Configuration file path: /etc/salt/master
[DEBUG   ] LazyLoaded flat.targets
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] Jinja search path: ['/var/cache/salt/master/files/base']
[DEBUG   ] Rendered data from file: /etc/salt/roster:
server01: {host: server01}

[DEBUG   ] Results of YAML rendering:
OrderedDict([('server01', OrderedDict([('host', 'server01')]))])
[DEBUG   ] LazyLoaded roots.envs
[DEBUG   ] Could not LazyLoad roots.init
[DEBUG   ] Updating roots fileserver cache
[TRACE   ] Lockfile /var/cache/salt/master/file_lists/roots/.base.w created
[TRACE   ] Lockfile /var/cache/salt/master/file_lists/roots/.base.w removed
[INFO    ] Fetching file from saltenv 'base', ** skipped ** latest already in cache 'salt://_grains/fusionio.py'
[DEBUG   ] LazyLoaded local_cache.prep_jid
[DEBUG   ] Could not LazyLoad cmd.run
[DEBUG   ] Performing shimmed, blocking command as follows:
cmd.run hostname
[DEBUG   ] Executing command: ssh server01  -o KbdInteractiveAuthentication=no -o PasswordAuthentication=yes -o GSSAPIAuthentication=no -o ConnectTimeout=65 -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile=/etc/salt/pki/master/ssh/salt-ssh.rsa -o User=myownuser  /bin/sh << 'EOF'
set -e
set -u
DEBUG="1"
if [ -n "$DEBUG" ]
then set -x
fi
SUDO=""
if [ -n "" ]
then SUDO="sudo "
fi
EX_PYTHON_OLD=10
PATH=/opt/python/bin:$PATH; export PATH
PYTHON_CMDS="python27 python2.7 python26 python2.6 python2 python"
for py_cmd in $PYTHON_CMDS
do if "$py_cmd" -c "import sys; sys.exit(not sys.hexversion >= 0x02060000);" >/dev/null 2>&1
then py_cmd_path=`"$py_cmd" -c 'import sys; print sys.executable;'`
exec $SUDO "$py_cmd_path" -c 'exec """IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KJycnClRoaXMgaXMgYSBzaGltIHRoYXQgaGFuZGxlcyBj
...SNIP...
YWluKHN5cy5hcmd2KSkK
""".decode("base64")'
exit 0
else continue
fi
done
echo "ERROR: Unable to locate appropriate python command" >&2
exit $EX_PYTHON_OLD
EOF
[DEBUG   ] Child Forked! PID: 26075  STDOUT_FD: 7  STDERR_FD: 9
[DEBUG   ] Terminal Command: /bin/sh -c ssh server01  -o KbdInteractiveAuthentication=no -o PasswordAuthentication=yes -o GSSAPIAuthentication=no -o
 ConnectTimeout=65 -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile=/etc/salt/pki/master/ssh/salt-ssh.rsa -o User=myownuser  /bin/sh << 'EOF'
set -e
set -u
DEBUG="1"
if [ -n "$DEBUG" ]
then set -x
fi
SUDO=""
if [ -n "" ]
then SUDO="sudo "
fi
EX_PYTHON_OLD=10
PATH=/opt/python/bin:$PATH; export PATH
PYTHON_CMDS="python27 python2.7 python26 python2.6 python2 python"
for py_cmd in $PYTHON_CMDS
do if "$py_cmd" -c "import sys; sys.exit(not sys.hexversion >= 0x02060000);" >/dev/null 2>&1
then py_cmd_path=`"$py_cmd" -c 'import sys; print sys.executable;'`
exec $SUDO "$py_cmd_path" -c 'exec """IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KJycnClRoaXMgaXMgYSBzaGltIHRoYXQgaGFuZGxlcyBj
YWluKHN5cy5hcmd2KSkK
""".decode("base64")'
exit 0
else continue
fi
done
echo "ERROR: Unable to locate appropriate python command" >&2
exit $EX_PYTHON_OLD
EOF
[DEBUG   ] + SUDO=
+ '[' -n '' ']'
+ EX_PYTHON_OLD=10
+ PATH=/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin
+ export PATH
+ PYTHON_CMDS='python27 python2.7 python26 python2.6 python2 python'
+ for py_cmd in '$PYTHON_CMDS'
+ python27 -c 'import sys; sys.exit(not sys.hexversion >= 0x02060000);'
+ continue
+ for py_cmd in '$PYTHON_CMDS'
+ python2.7 -c 'import sys; sys.exit(not sys.hexversion >= 0x02060000);'
++ python2.7 -c 'import sys; print sys.executable;'
+ py_cmd_path=/opt/python/bin/python2.7
+ exec /opt/python/bin/python2.7 -c 'exec """IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KJycnClRoaXMgaXMgYSBzaGltIHRoYXQgaGFuZGxlcyBj
...SNIP...
YWluKHN5cy5hcmd2KSkK
""".decode("base64")'
[DEBUG   ] STDOUT server01
_edbc7885e4f9aac9b83b35999b68d015148caf467b78fa39c05f669c0ff89878
deploy

[DEBUG   ] STDERR server01
+ SUDO=
+ '[' -n '' ']'
+ EX_PYTHON_OLD=10
+ PATH=/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin
+ export PATH
+ PYTHON_CMDS='python27 python2.7 python26 python2.6 python2 python'
+ for py_cmd in '$PYTHON_CMDS'
+ python27 -c 'import sys; sys.exit(not sys.hexversion >= 0x02060000);'
+ continue
+ for py_cmd in '$PYTHON_CMDS'
+ python2.7 -c 'import sys; sys.exit(not sys.hexversion >= 0x02060000);'
++ python2.7 -c 'import sys; print sys.executable;'
+ py_cmd_path=/opt/python/bin/python2.7
+ exec /opt/python/bin/python2.7 -c 'exec """IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KJycnClRoaXMgaXMgYSBzaGltIHRoYXQgaGFuZGxlcyBj
...SNIP...
YWluKHN5cy5hcmd2KSkK
""".decode("base64")'

[DEBUG   ] RETCODE server01: 11
[DEBUG   ] SHIM retcode(11) and command: deploy
[DEBUG   ] Executing command: scp   -o KbdInteractiveAuthentication=no -o PasswordAuthentication=yes -o GSSAPIAuthentication=no -o ConnectTimeout=65
 -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile=/etc/salt/pki/master/ssh/salt-ssh.rsa -o User=myownuser  /var/cache/salt/master/thin/thin.tgz
 server01:/tmp/.myownuser_28693a__salt/salt-thin.tgz
[DEBUG   ] Child Forked! PID: 26078  STDOUT_FD: 7  STDERR_FD: 9
[DEBUG   ] Terminal Command: /bin/sh -c scp   -o KbdInteractiveAuthentication=no -o PasswordAuthentication=yes -o GSSAPIAuthentication=no -o Connect
Timeout=65 -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile=/etc/salt/pki/master/ssh/salt-ssh.rsa -o User=myownuser  /var/cache/salt/master/thi
n/thin.tgz server01:/tmp/.myownuser_28693a__salt/salt-thin.tgz
thin.tgz                                        0%    0     0.0KB/s   --:-- ETA
thin.tgz                                      100% 4517KB   4.4MB/s   00:01
[DEBUG   ] Executing command: scp   -o KbdInteractiveAuthentication=no -o PasswordAuthentication=yes -o GSSAPIAuthentication=no -o ConnectTimeout=65
 -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile=/etc/salt/pki/master/ssh/salt-ssh.rsa -o User=myownuser  /var/cache/salt/master/ext_mods.23b7
dec50a5c9d23a6fbf917084b89617ba7cbf7.tgz server01:/tmp/.myownuser_28693a__salt/salt-ext_mods.tgz
[DEBUG   ] Child Forked! PID: 26081  STDOUT_FD: 7  STDERR_FD: 9
[DEBUG   ] Terminal Command: /bin/sh -c scp   -o KbdInteractiveAuthentication=no -o PasswordAuthentication=yes -o GSSAPIAuthentication=no -o Connect
Timeout=65 -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile=/etc/salt/pki/master/ssh/salt-ssh.rsa -o User=myownuser  /var/cache/salt/master/ext
_mods.23b7dec50a5c9d23a6fbf917084b89617ba7cbf7.tgz server01:/tmp/.myownuser_28693a__salt/salt-ext_mods.tgz
ext_mods.23b7dec50a5c9d23a6fbf917084b89617ba7 100%  369     0.4KB/s   00:00 ETA
[DEBUG   ] Executing command: ssh server01  -o KbdInteractiveAuthentication=no -o PasswordAuthentication=yes -o GSSAPIAuthentication=no -o ConnectTi
meout=65 -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile=/etc/salt/pki/master/ssh/salt-ssh.rsa -o User=myownuser  /bin/sh << 'EOF'
set -e
set -u
DEBUG="1"
if [ -n "$DEBUG" ]
then set -x
fi
SUDO=""
if [ -n "" ]
then SUDO="sudo "
fi
EX_PYTHON_OLD=10
PATH=/opt/python/bin:$PATH; export PATH
PYTHON_CMDS="python27 python2.7 python26 python2.6 python2 python"
for py_cmd in $PYTHON_CMDS
do if "$py_cmd" -c "import sys; sys.exit(not sys.hexversion >= 0x02060000);" >/dev/null 2>&1
then py_cmd_path=`"$py_cmd" -c 'import sys; print sys.executable;'`
exec $SUDO "$py_cmd_path" -c 'exec """IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KJycnClRoaXMgaXMgYSBzaGltIHRoYXQgaGFuZGxlcyBj
...SNIP...
YWluKHN5cy5hcmd2KSkK
""".decode("base64")'
exit 0
else continue
fi
done
echo "ERROR: Unable to locate appropriate python command" >&2
exit $EX_PYTHON_OLD
EOF
[DEBUG   ] Child Forked! PID: 26084  STDOUT_FD: 7  STDERR_FD: 9
[DEBUG   ] Terminal Command: /bin/sh -c ssh server01  -o KbdInteractiveAuthentication=no -o PasswordAuthentication=yes -o GSSAPIAuthentication=no -o
 ConnectTimeout=65 -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile=/etc/salt/pki/master/ssh/salt-ssh.rsa -o User=myownuser  /bin/sh << 'EOF'
set -e
set -u
DEBUG="1"
if [ -n "$DEBUG" ]
then set -x
fi
SUDO=""
if [ -n "" ]
then SUDO="sudo "
fi
EX_PYTHON_OLD=10
PATH=/opt/python/bin:$PATH; export PATH
PYTHON_CMDS="python27 python2.7 python26 python2.6 python2 python"
for py_cmd in $PYTHON_CMDS
do if "$py_cmd" -c "import sys; sys.exit(not sys.hexversion >= 0x02060000);" >/dev/null 2>&1
then py_cmd_path=`"$py_cmd" -c 'import sys; print sys.executable;'`
exec $SUDO "$py_cmd_path" -c 'exec """IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KJycnClRoaXMgaXMgYSBzaGltIHRoYXQgaGFuZGxlcyBj
...SNIP...
YWluKHN5cy5hcmd2KSkK
""".decode("base64")'
exit 0
else continue
fi
done
echo "ERROR: Unable to locate appropriate python command" >&2
exit $EX_PYTHON_OLD
EOF
[DEBUG   ] + SUDO=
+ '[' -n '' ']'
+ EX_PYTHON_OLD=10
+ PATH=/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin
+ export PATH
+ PYTHON_CMDS='python27 python2.7 python26 python2.6 python2 python'
+ for py_cmd in '$PYTHON_CMDS'
+ python27 -c 'import sys; sys.exit(not sys.hexversion >= 0x02060000);'
+ continue
+ for py_cmd in '$PYTHON_CMDS'
+ python2.7 -c 'import sys; sys.exit(not sys.hexversion >= 0x02060000);'
++ python2.7 -c 'import sys; print sys.executable;'
+ py_cmd_path=/opt/python/bin/python2.7
+ exec /opt/python/bin/python2.7 -c 'exec """IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KJycnClRoaXMgaXMgYSBzaGltIHRoYXQgaGFuZGxlcyBj
...SNIP...
YWluKHN5cy5hcmd2KSkK
""".decode("base64")'
SALT_ARGV: ['/opt/python/bin/python2.7', '/tmp/.myownuser_28693a__salt/salt-call', '--local', '--metadata', '--out', 'json', '-l', 'quiet', '-c', '/tmp/.myownuser_28693a__salt', '--', 'cmd.run', 'hostname']
_edbc7885e4f9aac9b83b35999b68d015148caf467b78fa39c05f669c0ff89878
[CRITICAL] Unable to import msgpack or msgpack_pure python modules
[DEBUG   ] Traceback (most recent call last):
  File "/tmp/.myownuser_28693a__salt/salt-call", line 4, in <module>
    salt_call()
  File "/tmp/.myownuser_28693a__salt/salt/scripts.py", line 225, in salt_call
    client.run()
  File "/tmp/.myownuser_28693a__salt/salt/cli/call.py", line 59, in run
    caller = salt.cli.caller.Caller.factory(self.config)
  File "/tmp/.myownuser_28693a__salt/salt/cli/caller.py", line 69, in factory
    return ZeroMQCaller(opts, **kwargs)
  File "/tmp/.myownuser_28693a__salt/salt/cli/caller.py", line 92, in __init__
    self.minion = salt.minion.SMinion(opts)
  File "/tmp/.myownuser_28693a__salt/salt/minion.py", line 298, in __init__
    opts['grains'] = salt.loader.grains(opts)
  File "/tmp/.myownuser_28693a__salt/salt/loader.py", line 463, in grains
    ret = fun()
  File "/tmp/.myownuser_28693a__salt/salt/grains/core.py", line 1173, in os_data
    grains.update(_linux_gpu_data())
  File "/tmp/.myownuser_28693a__salt/salt/grains/core.py", line 168, in _linux_gpu_data
    lspci_out = __salt__['cmd.run']('lspci -vmm')
  File "/tmp/.myownuser_28693a__salt/salt/modules/cmdmod.py", line 525, in _run_quiet
    saltenv=saltenv)['std
[DEBUG   ] out']
  File "/tmp/.myownuser_28693a__salt/salt/modules/cmdmod.py", line 392, in _run
    .format(cmd, kwargs, exc)
salt.exceptions.CommandExecutionError: Unable to run command ['lspci', '-vmm'] with the context {'with_communicate': True, 'shell': False, 'env': {'LESSOPEN': '|/usr/bin/lesspipe.sh %s', 'SSH_CLIENT': '10.64.158.95 45511 22', 'CVS_RSH': 'ssh', 'LOGNAME': 'myownuser', 'USER': 'myownuser', 'QTDIR':'/usr/lib64/qt-3.3', 'PATH': '/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin', 'LANG': 'en_US.UTF-8', 'QTLIB': '/usr/lib64/qt-3.3/lib', 'SHELL': '/bin/bash', 'CDC_JOINED_SITE': 'MAIN-Intranet', 'SHLVL': '1', 'G_BROKEN_FILENAMES': '1', 'CDC_JOINED_DOMAIN': 'msp.mycompany.net', 'USER_PRINCIPAL_NAME': '[email protected]', 'HOME': '/home/myownuser', 'CDC_JOINED_DC': 'mucmspdc25.msp.mycompany.net', 'CDC_PREW2KHOST': 'server01', 'LC_ALL': 'C', 'DA_SESSION_ID_AUTH': '8da9075b-4ba6-4d9b-8dc3-de4cfb7529a8', 'QTINC': '/usr/lib64/qt-3.3/include', 'PWD': '/home/ppdougla', 'CDC_JOINED_ZONE': 'CN=OSO05UNX_DBA_PRD_linux,CN=Zones,OU=OSO05UNX,OU=NIX,DC=msp,DC=mycompany,DC=net', 'CDC_LOCALHOST': 'server01.msp.mycompany.net', 'MAIL': '/var/mail/ppdougla', 'SSH_CONNECTION': '10.64.158.95 45511 172.17.194.148 22'}, 'stdout': -1, 'close_fds': True, 'stdin': None, 'stderr': -2, 'cwd': '/home/ppdougla'}, reason: [Errno 2] No such file or directory
[DEBUG   ] LazyLoaded nested.output
[TRACE   ] data = {'server01': {'retcode': 0, 'stderr': '[CRITICAL] Unable to import msgpack or msgpack_pure python modules\nTraceback (most recent call last):\n  File "/tmp/.myownuser_28693a__salt/salt-call", line 4, in <module>\n    salt_call()\n  File "/tmp/.myownuser_28693a__salt/salt/scripts.py", line 225, in salt_call\n   client.run()\n  File "/tmp/.myownuser_28693a__salt/salt/cli/call.py", line 59, in run\n    caller = salt.cli.caller.Caller.factory(self.config)\n  File "/tmp/.myownuser_28693a__salt/salt/cli/caller.py", line 69, in factory\n    return ZeroMQCaller(opts, **kwargs)\n  File "/tmp/.myownuser_28693a__salt/salt/cli/caller.py", line 92, in __init__\n    self.minion = salt.minion.SMinion(opts)\n  File "/tmp/.myownuser_28693a__salt/salt/minion.py", line 298, in __init__\n    opts[\'grains\'] = salt.loader.grains(opts)\n  File "/tmp/.myownuser_28693a__salt/salt/loader.py", line 463, in grains\n    ret = fun()\n  File "/tmp/.myownuser_28693a__salt/salt/grains/core.py", line 1173, in os_data\n    grains.update(_linux_gpu_data())\n  File "/tmp/.myownuser_28693a__salt/salt/grains/core.py", line 168, in _linux_gpu_data\n    lspci_out = __salt__[\'cmd.run\'](\'lspci -vmm\')\n  File "/tmp/.myownuser_28693a__salt/salt/modules/cmdmod.py", line 525, in _run_quiet\n    saltenv=saltenv)[\'stdout\']\n  File "/tmp/.myownuser_28693a__salt/salt/modules/cmdmod.py", line 392, in _run\n    .format(cmd, kwargs, exc)\nsalt.exceptions.CommandExecutionError: Unable to run command [\'lspci\', \'-vmm\'] with the context {\'with_communicate\': True, \'shell\': False, \'env\': {\'LESSOPEN\': \'|/usr/bin/lesspipe.sh %s\', \'SSH_CLIENT\': \'10.64.158.95 45511 22\', \'CVS_RSH\': \'ssh\', \'LOGNAME\': \'myownuser\', \'USER\': \'myownuser\', \'QTDIR\': \'/usr/lib64/qt-3.3\', \'PATH\': \'/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin\', \'LANG\': \'en_US.UTF-8\', \'QTLIB\': \'/usr/lib64/qt-3.3/lib\', \'SHELL\': \'/bin/bash\', \'CDC_JOINED_SITE\': \'MAIN-Intranet\', \'SHLVL\': \'1\', \'G_BROKEN_FILENAMES\': \'1\', \'CDC_JOINED_DOMAIN\': \'msp.mycompany.net\', \'USER_PRINCIPAL_NAME\': \'[email protected]\', \'HOME\': \'/home/myownuser\', \'CDC_JOINED_DC\': \'mucmspdc25.msp.mycompany.net\', \'CDC_PREW2KHOST\': \'server01\', \'LC_ALL\': \'C\', \'DA_SESSION_ID_AUTH\': \'8da9075b-4ba6-4d9b-8dc3-de4cfb7529a8\', \'QTINC\': \'/usr/lib64/qt-3.3/include\', \'PWD\': \'/home/myownuser\', \'CDC_JOINED_ZONE\': \'CN=OSO05UNX_DBA_PRD_linux,CN=Zones,OU=OSO05UNX,OU=NIX,DC=msp,DC=mycompany,DC=net\', \'CDC_LOCALHOST\': \'server01.msp.mycompany.net\', \'MAIL\': \'/var/mail/myownuser\', \'SSH_CONNECTION\': \'10.64.158.95 45511 172.17.194.148 22\'}, \'stdout\': -1, \'close_fds\': True, \'stdin\': None, \'stderr\': -2, \'cwd\': \'/home/myownuser\'}, reason: [Errno 2] No such file or directory', 'stdout': ''}}
server01:
    ----------
    retcode:
        0
    stderr:
        [CRITICAL] Unable to import msgpack or msgpack_pure python modules
        Traceback (most recent call last):
          File "/tmp/.myownuser_28693a__salt/salt-call", line 4, in <module>
            salt_call()
          File "/tmp/.myownuser_28693a__salt/salt/scripts.py", line 225, in salt_call
            client.run()
          File "/tmp/.myownuser_28693a__salt/salt/cli/call.py", line 59, in run
            caller = salt.cli.caller.Caller.factory(self.config)
          File "/tmp/.myownuser_28693a__salt/salt/cli/caller.py", line 69, in factory
            return ZeroMQCaller(opts, **kwargs)
          File "/tmp/.myownuser_28693a__salt/salt/cli/caller.py", line 92, in __init__
            self.minion = salt.minion.SMinion(opts)
          File "/tmp/.myownuser_28693a__salt/salt/minion.py", line 298, in __init__
            opts['grains'] = salt.loader.grains(opts)
          File "/tmp/.myownuser_28693a__salt/salt/loader.py", line 463, in grains
            ret = fun()
          File "/tmp/.myownuser_28693a__salt/salt/grains/core.py", line 1173, in os_data
            grains.update(_linux_gpu_data())
          File "/tmp/.myownuser_28693a__salt/salt/grains/core.py", line 168, in _linux_gpu_data
            lspci_out = __salt__['cmd.run']('lspci -vmm')
          File "/tmp/.myownuser_28693a__salt/salt/modules/cmdmod.py", line 525, in _run_quiet
            saltenv=saltenv)['stdout']
          File "/tmp/.myownuser_28693a__salt/salt/modules/cmdmod.py", line 392, in _run
            .format(cmd, kwargs, exc)
        salt.exceptions.CommandExecutionError: Unable to run command ['lspci', '-vmm'] with the context {'with_communicate': True, 'shell': False, 'env': {'LESSOPEN': '|/usr/bin/lesspipe.sh %s', 'SSH_CLIENT': '10.10.10.11 45511 22', 'CVS_RSH': 'ssh', 'LOGNAME': 'myownuser', 'USER': 'myownuser', 'QTDIR': '/usr/lib64/qt-3.3', 'PATH': '/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin', 'LANG': 'en_US.UTF-8', 'QTLIB': '/usr/lib64/qt-3.3/lib', 'SHELL': '/bin/bash', 'CDC_JOINED_SITE': 'MAIN-Intranet', 'SHLVL': '1', 'G_BROKEN_FILENAMES': '1', 'CDC_JOINED_DOMAIN': 'msp.mycompany.net', 'USER_PRINCIPAL_NAME': '[email protected]', 'HOME': '/home/myownuser', 'CDC_JOINED_DC': mycompanypdc25.msp.mycompany.net', 'CDC_PREW2KHOST': 'server01', 'LC_ALL': 'C', 'DA_SESSION_ID_AUTH': '8da9075b-4ba6-4d9b-8dc3-de4cfb7529a8', 'QTINC': '/usr/lib64/qt-3.3/include', 'PWD': '/home/myownuser', 'CDC_JOINED_ZONE': 'CN=PRD_linux,CN=Zones,OU=NIX,DC=msp,DC=mycompany,DC=net', 'CDC_LOCALHOST': 'server01.msp.mycompany.net', 'MAIL': '/var/mail/myownuser', 'SSH_CONNECTION': '10.10.10.12 45511 172.17.194.148 22'}, 'stdout': -1, 'close_fds': True, 'stdin': None, 'stderr': -2, 'cwd': '/home/myownuser'}, reason: [Errno 2] No such file or directory
    stdout:

philipsd6 avatar May 06 '15 20:05 philipsd6

Interestingly, that last command in the trace:

SALT_ARGV: ['/opt/python/bin/python2.7', '/tmp/.myownuser_28693a__salt/salt-call', '--local', '--metadata', '--out', 'json', '-l', 'quiet', '-c', '/tmp/.myownuser_28693a__salt', '--', 'cmd.run', 'hostname']

If I run that on the target server manually, it works as expected:

[myownuser@server01 ~]$ /opt/python/bin/python2.7 /tmp/.myownuser_28693a__salt/salt-call --local --metadata --out json -l debug -c /tmp/.myownuser_28693a__salt/ -- cmd.run hostname
[CRITICAL] Unable to import msgpack or msgpack_pure python modules
[DEBUG   ] LOGGING_NULL_HANDLER is already None, can't sync messages with it
[DEBUG   ] Reading configuration from /tmp/.myownuser_28693a__salt/minion
[WARNING ] Console logging already configured
[CRITICAL] Unable to import msgpack or msgpack_pure python modules
[WARNING ] Console logging already configured
[DEBUG   ] Configuration file path: /tmp/.myownuser_28693a__salt/minion
[DEBUG   ] Reading configuration from /tmp/.myownuser_28693a__salt/minion
[DEBUG   ] The `lspci` binary is not available on the system. GPU grains will not be available. lspci = '/sbin/lspci'.
[WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded cmd.run
[INFO    ] Executing command 'hostname' in directory '/home/myownuser'
[DEBUG   ] output: server01
[DEBUG   ] LazyLoaded json.output
{
    "local": {
        "fun_args": [
            "hostname"
        ],
        "jid": "20150506201551375797",
        "return": "server01",
        "retcode": 0,
        "fun": "cmd.run",
        "id": "server01"
    }
}

philipsd6 avatar May 06 '15 20:05 philipsd6

Sorry to make you go through all that effort. I was hoping to get this trace message, which did not appear. Would you mind trying this patch? Thanks.

jfindlay avatar May 06 '15 22:05 jfindlay

Well that patch worked, but now I'm getting this:

salt.exceptions.CommandExecutionError: Unable to run command ['dmidecode'] with the context...

So it would seem to be a deeper issue requiring more generalized changes…

philipsd6 avatar May 07 '15 00:05 philipsd6

So, salt.utils.which is finding executable commands on the system but the salt-ssh environment is not, which is somewhat strange.

jfindlay avatar May 07 '15 07:05 jfindlay

For reference, here is the patch. As @philipsd6 indicates, a better solution is here needed. I am persuaded that all uses of executables at least in core grains should use the path returned by salt.utils.which, this issue being an example for reasons as to why.

--- a/salt/grains/core.py
+++ b/salt/grains/core.py
@@ -161,7 +161,7 @@ def _linux_gpu_data():

     devs = []
     try:
-        lspci_out = __salt__['cmd.run']('lspci -vmm')
+        lspci_out = __salt__['cmd.run']([lspci, '-vmm'], python_shell=False)

         cur_dev = {}
         error = False

jfindlay avatar May 07 '15 07:05 jfindlay

Additional reports on this not being fixed present in duplicate issue #23618

cachedout avatar May 13 '15 06:05 cachedout

In my case, lspci are installed and can be run in target, the problem is 2015.5.0 because with 2014.7.5 all works fine!

Mstaaravin avatar May 13 '15 11:05 Mstaaravin

I just did some testing and I've gotten past this issue by adding /sbin and /usr/sbin to the shim's PATH. My Salt bootstrap script, after installing salt on the master, immediately runs this:

sed -i '/PYTHON_CMDS=/i\PATH=/opt/path/to/my/python27:$PATH; export PATH' \
                /usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py
salt-run thin.generate overwrite=1

This is to make sure it can find our non-standard python27 installed in a custom location on our RHEL systems that only have python24 available. (I know it's kind of a weird hack, but I couldn't figure out any documented way to handle this situation.)

I updated that sed command to include /sbin and /usr/sbin in my customized PATH and I was able to use salt-ssh on those servers that were affected by this issue.

philipsd6 avatar May 21 '15 15:05 philipsd6

Experiencing the same issue on RHEL 6.4/salt 2015.5.0 (failing to find lspci/dmidecode resulting in salt-ssh crashing out), patch provided earlier did not seem to resolve any of the issues. No issue with salt 2014.7.5

What I am seeing is salt-ssh getting /usr/local/bin:/bin:/usr/bin set as the path and failing to find lspci/dmidecode (which sit in /sbin and /usr/sbin respectively), sshing into the host myself additionally gives /usr/local/sbin:/usr/sbin:/sbin on the path.

My fix for the moment has been to add the correct PATH as an export within the SSH_SH_SHIM before the PYTHON_CMDS entry in salt/client/ssh/init.py.

adrianhj avatar May 22 '15 09:05 adrianhj

This issue can be easily reproduced by (log in to Linux minion):

unset PATH
PATH=/bin:/usr/bin
salt-call state.show_top

This will ends with the same exception:

salt.exceptions.CommandExecutionError: Unable to run command ['lspci', '-vmm'] with ...

dsumsky avatar May 26 '15 15:05 dsumsky

Release 2015.5.1 still suffers from this issue. Any idea when it could be fixed?!?

dsumsky avatar May 28 '15 12:05 dsumsky

I think @philipsd6 workaround is the best bet thus far. Otherwise, if you can figure a way to set enable_gpu_grains: False via minion_opts that should help too (see #24163)

tbaker57 avatar May 29 '15 08:05 tbaker57

Yeah, @tbaker57 Setting enable_gpu_grains: False via minion_opts was the first thing I tried, but as you noted in #24163, it had no effect on salt-ssh.

philipsd6 avatar May 29 '15 13:05 philipsd6

@dsumsky Out of curiosity, what's your ideal resolution of this issue? If the minion can't find the necessary commands, should it abort gracefully, skip those grains, or what? I'm not going to have it start searching arbitrary directories, it should obey the PATH.

basepi avatar Jun 03 '15 22:06 basepi

Nevermind, I totally see what's going on here. We check for nonzero retcodes, but since we switched to python_shell=False, commands which are not found throw exceptions rather than just having non-zero retcodes. I'm going to test this fix, should be incoming soon.

basepi avatar Jun 03 '15 22:06 basepi

Should be fixed with #24382. That fix probably won't hit 2015.5.2, because I think it was tagged internally today. But it will be in 2015.5.3. Would appreciate some testing.

basepi avatar Jun 03 '15 22:06 basepi

@basepi - I've tried this with the current head of 2015.5 and it now works for me :thumbsup:

cheers, Tim

tbaker57 avatar Jun 09 '15 21:06 tbaker57

Likewise — I just re-bootstrapped develop and it works without my monkeying around with the shim PATH :+1:

(I still have to shovel in our non-standard Python location in to the PATH tho')

philipsd6 avatar Jun 09 '15 21:06 philipsd6