saltstack远程操作WINDOWS的POWERSHELL脚本
这个东东,花了两天来查找资料和测试,终于算是搞定。作记录:
直接在MASTER上执行的命令:
salt '*' cmd.script salt://scripts/windows_task.ps1 args=' -Input c:\tmp\infile.txt' shell='powershell'
直接通过SALT-API执行的命令:
curl -k https://127.0.0.1:8000/ -H "Accept: application/x-yaml" -H "X-Auth-Token: 0ef19709d068834637758b1b5a9af6927a7a651d" -d client='local' -d tgt='cnsz121685-10.25.174.81' -d fun='cmd.script' -d arg='salt://tengine_root/autodeploy/opscripts/test/sbp.ps1' -d arg="static ADE 20160127091855DB backup" -d arg='shell=powershell'
通过我们的API传参考:
if server_sys == 'LINUX':
args = [salt_cmd.strip(), server_type+' '+site_name+' '+app+' '+deploy_version+' '+action, 'runas='+op_name]
if server_sys == 'WINDOWS':
args = [salt_cmd.strip(), server_type+' '+site_name+' '+app+' '+deploy_version+' '+action, 'shell=powershell']
result = saltapi_inst(server_env).cmd_script(tgt, args)
而自制API用了REQUESTS。
def cmd_script(self, tgt, arg, expr_form='compound', fun='cmd.script'):
r = requests.post(self.host, verify=False, cookies=self.cookies, data={'tgt': tgt,
'client': 'local',
'expr_form': expr_form,
'fun': fun,
'arg': arg})
if r.status_code == 200:
# print r.json()
return r.json()
else:
raise Exception('Error from source %s' % r.text)
saltstack远程操作WINDOWS的POWERSHELL脚本的更多相关文章
- SaltStack远程执行Windows job程序(黑窗口)填坑经过
近期接到领导通知,要将公司内的所有Windows服务添加到自动发布系统中,由于这种服务很多,节点分布散乱,每次都是由开发主管手动替换(虽然他们自己开发了自动打包替换工具,但仍需要一台一台登陆到服务器上 ...
- 【转】PowerShell入门(六):远程操作
转至:http://www.cnblogs.com/ceachy/archive/2013/02/20/PowerShell_Remoting.html PowerShell远程操作是远程管理的基础, ...
- Windows 上的 SSH?使用 PowerShell Remoting 远程管理 Windows 服务器
作者:陈计节 个人博客:https://blog.jijiechen.com/post/powershell-remoting/ 在 Linux/Unix 世界里 SSH 是个好东西,SSH 是 Se ...
- powershell脚本之windows服务与进程
powershell脚本之windows服务与进程 服务与进程的区别: Windows服务是指系统自动完成的,不需要和用户交互的过程,可长时间运行的可执行应用程序 进程是程序运行的实例,系统会给运行中 ...
- 使用Windows Azure PowerShell远程管理Windows Azure虚拟机
对于Windows Azure,如果你还在使用windowsazure.com门户来管理虚拟机,那就显得不怎么高上大了.Windows Azure PowerShell 是一个功能强大的脚本环境,可用 ...
- 使用Windows任务计划程序运行Windows PowerShell脚本
创建计划任务以运行PowerShell脚本 我需要创建一个计划任务来运行Windows PowerShell脚本的第一件事是我将执行的命令行.找到这个的简单方法是使用Run 命令.有时,我需要知道什么 ...
- 【黑客基础】Windows PowerShell 脚本学习(上)
视频地址:[黑客基础]Windows PowerShell 脚本学习 2019.12.05 学习笔记 1.$PSVersionTable :查看PowerShell的版本信息. 2.PowerShel ...
- 如何在windows计划中调用备份sharepoint2010网站集的powershell脚本
最近有个项目需要在在windows计划中使用powershell脚本备份sharepoint2010网站集,打开sharepoint的powershell执行命令管理界面的属性 查看: C:\Wind ...
- loadrunner 脚本开发-调用java jar文件远程操作Oracle数据库测试
调用java jar文件远程操作Oracle数据库测试 by:授客 QQ:1033553122 测试环境 数据库:linux 下Oracle_11g_R2 Loadrunner:11 备注:想学ora ...
随机推荐
- android控件的属性
android控件的属性 本节描述android空间的位置,内容等相关属性及属性的含义 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 ( ...
- Cocos2d-x中使用音频CocosDenshion引擎介绍与音频文件的预处理
Cocos2d-x提供了一个音频CocosDenshion引擎,CocosDenshion引擎可以独立于Cocos2d-x单独使用,CocosDenshion引擎本质上封装了OpenAL音频处理库.具 ...
- Cocos2d-x实例:单点触摸事件
addChild(boxC,30, kBoxC_Tag); ...
- OC3_歌词解析
// // LrcManager.h // OC3_歌词解析 // // Created by zhangxueming on 15/6/15. // Copyright (c) 2015年 zhan ...
- H5API——Canvas
http://item.jd.com/11241807.html HTML5移动Web开发实战http://item.jd.com/10982275.html HTML5程序设计(第2版)http:/ ...
- 最小化Spring XML配置
Spring提供两种技巧,可以帮助我们减少XML的配置数量. 1.自动装配(autowiring)有助于减少甚至消除配置<property>元素和<constructor-arg&g ...
- 编译安装php Cannot find MySQL header files under /usr/include/mysql.
编译php-5.5-6的mysql支持,出现Cannot find MySQL header files under /usr/include/mysql. Note that the MySQL c ...
- 上传图片(基于zepto.js)
效果如下: <div class="otherPic"> <div id="showOtherImage"></div> & ...
- Looper Handler 多线程
Looper is created by default on main UI Property: // main ui thread, if Looper is initiali ...
- AngularJS(5)-Http
$http 是 AngularJS 中的一个核心服务,用于读取远程服务器的数据 加入下面有一个存储在web服务器上的数据,假设地址为http://TestWebData/myData.php { &q ...