1、SaltStack版本兼容性的问题说明
saltstack 2017.1以后发布的版本中,已经不再兼容支持python2.6。官方声称对core functionality部分仍然可以保持兼容性,但针对大量的第三方modules,例如MySQLdb,已经不再提供支持。因为RHEL6/CENTOS6系统默认使用的均是python2.6,所以一旦人为升级了saltstack版本至2017.1或更新的版本,可能就会面临这样的挑战——以前基于python2.6兼容的功能模块所开发的saltstack应用,将无法使用。详情参见下面链接。
https://github.com/saltstack/salt/issues/42979
如果你使用的是RHEL/CENTOS6系统,且已经对系统中的saltstack版本升级到了2017.1之后的版本,你会发现在升级的过程中安装了一个python2.7,以及少量几个python2.7使用的功能模块软件包,例如 pycrypto: 2.6.1 。
因此,当salt master和salt minion的版本都升级至2017.1后的相同版本时,即使你的salt minion是运行在RHEL6/CENTOS6上面的,仍然可以正常运行salt的核心功能模块,例如cmd,cp.push,cp.get_file等。原因就在于salt minion是使用的自带的python2.7环境和已经安装了的几个必要的功能模块。
引时查看salt minon的版本信息,会大致显示如下:
$ salt-call --versions-report
Salt Version:
Salt: 2017.7.2
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.8.1
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.13 (default, Jul 12 2017, 17:32:34)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.5.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
2、对于大量的第三方python模块,saltstack自带的python2.7环境中均未提供,凡是使用这类第三方python模块实现的功能这时都会失灵
# salt mytest mysql.query mydb "show tables"
gqtest:
'mysql' __virtual__ returned False: The mysql execution module cannot be loaded: neither MySQLdb nor PyMySQL is available.
3、针对RHEL6/CENTOS6系统升级salt minon至2017.7版本后,解决缺少依赖的第三方python2.7模块的方法
yum -y install mysql-devel python27-devel
yum -y install python27-pip
pip2.7 install MySQL-python
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
# salt-call --versions-report
Salt Version:
Salt: 2017.7.2
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.8.1
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: 1.2.5
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.13 (default, Jul 12 2017, 17:32:34)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.5.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
4、执行一个salt的mysql.query模块操作命令验证一下
salt mytest mysql.query temp "select count(*) from xiangdan"
mytest:
----------
columns:
- count(*)
query time:
----------
human:
3.7ms
raw:
0.00374
results:
|_
- 3065
rows returned:
1