gen_inventory.py 574 Bytes
#!/usr/bin/env python
# coding=utf-8

""""
   generate ansible inventory files from auto-deploy: http://git.yoho.cn/yohoops/auto_deploy/tree/master/scripts/iptable
"""


import json
import os
from subprocess import call

PATH = "~/.tmp/auto_deploy"

# clone deploy project to local
if os.path.isdir(PATH):
    call("rm -rf %s" % PATH , shell=True)

call("mkdir -p %s"  % PATH, shell=True)
call("git clone  --recursive git@git.yoho.cn:yohoops/auto_deploy.git  %s" % PATH, shell=True)




print("success write ansible inventory hosts files to file: [inventory_hosts]")