saltstack的runner manage提供了常用的管理操作:
salt-run manage.up
显示当前活着的minionsalt-run manage.down
显示未存活的minionsalt-run manage.down removekeys=True
显示未存活的minion,并将其删除salt-run manage.status
显示当前up和down的minionsalt-run manage.versions
显示Master和所有minion的版本,可以通过此命令找到版本不一致的minion可以通过下面代码片段快速找到需要更新的salt-minion
minions = client.cmd('*', 'test.version', timeout=__opts__['timeout']) # 通过client.cmd方法下发所有minion需要执行test.version(输出版本号)的指令labels = { # 定义版本对比的描述 -1: 'Minion requires update', 0: 'Up to date', 1: 'Minion newer than master',}version_status = {}comps = salt.__version__.split('-') # 获取master versionif len(comps) == 3: master_version = '-'.join(comps[0:2])else: master_version = salt.__version__for minion in minions: comps = minions[minion].split('-') if len(comps) == 3: minion_version = '-'.join(comps[0:2]) else: minion_version = minions[minion] ver_diff = cmp(minion_version, master_version) # 通过python的cmp方法对版本号进行对比 if ver_diff not in version_status: version_status[ver_diff] = [] version_status[ver_diff].append(minion)ret = {}for key in version_status: for minion in sorted(version_status[key]): ret.setdefault(labels[key], []).append(minion)salt.output.display_output(ret, '', __opts__)return ret
manage.safe_accept 用来接收minion
salt-run manage.safe_accept my_minion salt-run manage.safe_accept minion1,minion2 expr_form=list
原文链接:http://outofmemory.cn/saltstack/manage-command