Wednesday, 25 May 2016

SALT-SSH: AttributeError: 'module' object has no attribute 'fromstringlist'

This error triggers when the salt-master is CentOS6 and the target is CentOS7. 
The salt-master on CentOS6 would copy ElementTree.py to the minion on CentOS7 but 
python2.6's lib cannot run directly on python2.7.

To overcome this issue,

On the salt-master:

1). Find the thin.py

# find / -name thin.py
/usr/lib/python2.6/site-packages/salt/runners/thin.py
/usr/lib/python2.6/site-packages/salt/utils/thin.py

In /usr/lib/python2.6/site-packages/salt/utils/thin.py

try:
    import xml
    HAS_XML = True
except ImportError:
    HAS_XML = False

Modify as:

try:
    import xml
    HAS_XML = False
except ImportError:
    HAS_XML = False


2). remove the thin.tgz from cache

# rm /var/cache/salt/master/thin/thin.tgz

3). Perform the salt-ssh command again with -W
( -W for Select a random temp dir to deploy on the remote system. The dir will be cleaned
after the execution.)

# salt-ssh -W rnd test.ping

# salt-ssh -W rnd disk.usage