码迷,mamicode.com
首页 > 数据库 > 详细

ansible runner把结果写入MongoDB

时间:2014-09-28 18:51:37      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:ansible runner mongodb

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)



ansible runner把结果写入MongoDB

标签:ansible runner mongodb

原文地址:http://jasonyu37.blog.51cto.com/8877469/1559087

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!