salt icon indicating copy to clipboard operation
salt copied to clipboard

salt-ssh commands are mostly broken after SaltStack update

Open Learner11 opened this issue 12 years ago • 13 comments

I recently updated SaltStack and Salt-SSH on an Oracle Linux server (with the yum install commands for both). Now salt-ssh commands are mostly broken. When I run this: salt-ssh '*' test.ping I get "retcode: 1" and this is the most recent part of the traceback:

File "/tmp/.root_778742__salt/urllib3/connectionpool.py", line 63, in <module> from     
.packages.ssl_match_hostname import match_hostname, CertificateError
ImportError: No module named packages.ssl_match_hostname stdout:

I therefore did this: pip install backports.ssl_match_hostname

But that requirement was already satisfied. I'm using Python 2.6.6.

Why won't the salt-ssh commands work now? A test.ping is very simple. The salt-ssh -r (raw shell commands) still work. It all broke after I updated the Salt Master and salt-ssh.

Learner11 avatar Nov 14 '14 06:11 Learner11

I remember seeing this issue yesterday while testing salt-ssh but I don't remember what exactly I installed or upgraded to fix it. Will you provide the output of salt --versions and also tell which version of salt you were using before upgrading? Thanks.

jfindlay avatar Nov 14 '14 17:11 jfindlay

Before the upgrade I was using Salt: 2014.1.13 After the upgrade I use Salt: 2014.7.0

salt --versions:
Salt: 2014.7.0
Python (2.6.6)
Jinja2: 2.2.1
M2Crypto: 0.20.2
msgpack-python: 0.1.13
msgpack-pure: 0.1.3
pycrypto: 2.0.1
lbnacl: Not installed
PyYAML: 3.10
ioflo: Not installed
PyZMQ: 14.3.1
RAET: Not Installed
ZMQ: 3.2.4
Marko: Not Installed

Learner11 avatar Nov 15 '14 18:11 Learner11

Can you verify that backports.ssl_match_hostname is installed? On CentOS 7 I am able to install it from the CentOS repository. You could try something like rpm -qa | grep ssl_match_hostname and/or pip list | grep ssl. For me these are the files that copy over to the remote host over salt-ssh:

# find /tmp/.root_960548__salt/ | grep ssl_match_hostname
/tmp/.root_960548__salt/requests/packages/urllib3/packages/ssl_match_hostname
/tmp/.root_960548__salt/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py
/tmp/.root_960548__salt/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py
/tmp/.root_960548__salt/urllib3/packages/ssl_match_hostname
/tmp/.root_960548__salt/urllib3/packages/ssl_match_hostname/__init__.py

Can you verify whether these files are in /tmp/_root_*__salt/? Thanks.

jfindlay avatar Nov 19 '14 20:11 jfindlay

How was requests installed? Packages or pip?

thatch45 avatar Nov 19 '14 21:11 thatch45

I see the same result with salt installed from EPEL on CentOS 6.5.

# yum info salt-ssh
...
Installed Packages
Name        : salt-ssh
Arch        : noarch
Version     : 2014.7.0
Release     : 3.el6
Size        : 2.8 k
Repo        : installed
From repo   : epel
Summary     : Agentless SSH-based version of Salt, a parallel remote execution system
URL         : http://saltstack.org/
License     : ASL 2.0
Description : The salt-ssh tool can run remote execution functions and states without the use
            : of an agent (salt-minion) service.

# cat /etc/redhat-release
CentOS release 6.5 (Final)
# salt --versions-report
           Salt: 2014.7.0
         Python: 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
         Jinja2: 2.2.1
       M2Crypto: 0.20.2
 msgpack-python: 0.1.13
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 14.3.1
           RAET: Not Installed
            ZMQ: 3.2.4
           Mako: Not Installed

ssl_match_hostname is installed as a dependency of package python-urllib3 and python-urllib3 is a dependency of python-requests so neither of them embed ssl_match_hostname and it ends up not being picked up in salt-thin.tgz:

# rpm -q --requires python-requests
ca-certificates
python(abi) = 2.6
python-chardet
python-ordereddict
python-urllib3
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1

# rpm -q --requires python-urllib3
ca-certificates
python(abi) = 2.6
python-backports-ssl_match_hostname
python-ordereddict
python-six
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1

Installing python-backports on the target system (if it is running CentOS) fixes the problem but ssl_match_hostname should probably be tested for separately and included in salt-thin.tgz. Something like:

try:
    # Older python where the backport from pypi is installed
    from backports import ssl_match_hostname
    HAS_SSL_MATCH_HOSTNAME = True
except ImportError:
    # Other older python we use our bundled copy
    try:
        from requests.packages.urllib3.packages import ssl_match_hostname
        HAS_SSL_MATCH_HOSTNAME = True
    except ImportError:
        HAS_SSL_MATCH_HOSTNAME = False

then:

    if HAS_SSL_MATCH_HOSTNAME:
        tops.append(os.path.dirname(os.path.dirname(ssl_match_hostname.__file__)))

cvedel avatar Nov 20 '14 22:11 cvedel

This helps, thanks! I will try to get a better picture of this on centos 6.5

thatch45 avatar Nov 21 '14 00:11 thatch45

Here was the solution for my problem.

On the client server (minionless client), I needed to install two programs:

  1. pip (python get-pip.py)
  2. backports (pip install backports.ssl_match_hostname)

Learner11 avatar Nov 24 '14 06:11 Learner11

@tbaker57, see comments in #18425

pitatus avatar Dec 05 '14 18:12 pitatus

Thanks @pitatus for the solution for this issue. I don't understand if/how salt-ssh is supposed to handle python dependencies on the target system. If it doesn't bundle them inside the salt-thin tarball, then the next best thing is to document the dependencies for common systems (Centos/RHEL, Ubuntu/Debian etc) in the official documentation. Anyway, thanks again for your help !

cheers, Tim

tbaker57 avatar Dec 07 '14 03:12 tbaker57

@tbaker57 that is the issue here.. those dependencies are supposed to be bundled so now relying on this issue (#18083 and #18425) to get the problem solved. thanks for the input!

pitatus avatar Dec 08 '14 15:12 pitatus

Can someone please test this against the latest 2015.5.2 release of salt? I feel like this has been fixed...

basepi avatar Jun 16 '15 22:06 basepi

Fixed for me with the following configuration:

# cat /etc/redhat-release
CentOS release 6.6 (Final)
# salt --versions
           Salt: 2015.5.0
         Python: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
         Jinja2: unknown
       M2Crypto: 0.20.2
 msgpack-python: 0.4.6
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 14.3.1
           RAET: Not Installed
            ZMQ: 3.2.5
           Mako: Not Installed

cvedel avatar Jun 22 '15 13:06 cvedel

Alright, I'm going to close this for now. If anyone is still experiencing this in the 2015.5 releases of salt, please tell us!

basepi avatar Jun 22 '15 18:06 basepi