Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ansible runner writes the result to MongoDB

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report