saltstack牛哄哄的,我是使用源码安装的,测试新版本后,保障能更新最新版本。
写一个模块如:upgrade.py,调用模块里面的方法实现升级saltstack版本(使用pip) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #!/usr/bin/env python # -*- coding: utf-8 -*- # tanyewei@gmail.com # 2013/12/16 16:14 import subprocess def version ( ) : return '0.0.1' def salt ( version = None , upgrade = True ) : ''' pip升级saltstack ''' result = { } if version : salt_up = __salt__ [ 'pip.install' ] ( pkgs = 'salt=={version}' . format ( version = version ) , upgrade = upgrade , bin_env = '/usr/local/saltstack/bin/pip' ) result . setdefault ( 'salt upgrade' , { } ) . setdefault ( 'stdout' , salt_up [ 'stdout' ] ) result . setdefault ( 'salt upgrade' , { } ) . setdefault ( 'stderr' , salt_up [ 'stderr' ] ) result . setdefault ( 'salt upgrade' , { } ) . setdefault ( 'retcode' , salt_up [ 'retcode' ] ) else : salt_up = __salt__ [ 'pip.install' ] ( pkgs = 'salt' , upgrade = upgrade , bin_env = '/usr/local/saltstack/bin/pip' ) result . setdefault ( 'salt upgrade' , { } ) . setdefault ( 'stdout' , salt_up [ 'stdout' ] ) result . setdefault ( 'salt upgrade' , { } ) . setdefault ( 'stderr' , salt_up [ 'stderr' ] ) result . setdefault ( 'salt upgrade' , { } ) . setdefault ( 'retcode' , salt_up [ 'retcode' ] ) salt_restart = str ( __salt__ [ 'service.restart' ] ( 'salt-minion' ) ) result . setdefault ( 'salt restart' , { } ) . setdefault ( 'result' , str ( salt_restart ) ) result . setdefault ( 'salt version' , { } ) . setdefault ( 'version' , __grains__ [ 'saltversion' ] ) return result |
加了个version方法,这样调用version可以查看minion端是否为最新的模块。