Http://rfyiamcool.blog.51cto.com/1030776/1440624 http://rfyiamcool.blog.51cto.com/1030776/1422263 root@
Http://rfyiamcool.blog.51cto.com/1030776/1440624
http://rfyiamcool.blog.51cto.com/1030776/1422263
root@ubuntu12:~/ansible# vi monGo.py
import sys
import pymongo
import ansible.runner
def log(res):
conn = pymongo.Connection(host="localhost", port=27017)
db = conn ["ansible"]
if type(res) == dict:
db.ansible.insert(res)
if __name__ == "__main__":
runner = ansible.runner.Runner(
module_name = 'shell',
module_args = 'ls -l',
pattern = 'Centos5',
)
result = runner.run()
log(result)
--结束END--
本文标题: ansible runner把结果写入MongoDB
本文链接: https://lsjlt.com/news/40186.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0