python调用rundeck的webhook并向作业传递参数的简单实现

python脚本如下:

# -*- coding: utf-8 -*-
import json
import requests
content = '{"field1":"","field2":"","field3":""}'        #准备传递给rundeck作业的参数
payload = json.loads(content)
payload["field1"] = "192.168.8.8"                        #参数1         
payload["field2"] = "\"ls /tmp >> /tmp/testssss.txt\""   #参数2
payload["field3"] = "root"                               #参数3
headers = { 'Content-Type': 'application/json',}
url = "http://192.168.*.*:4440/api/35/webhook/*****rundeck类似于token的值#pwhok"
response = requests.request("POST", url, headers=headers, data = json.dumps(payload))
print(response.text.encode('utf8'))

rundeck Webhooks 的配置

 

执行python脚本,即自动调用rundeck并传递参数

 

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页