Created by
T. Budiman
| #!/usr/bin/env python3
try:
import json
except ImportError:
import simplejson as json
with open('ec2list.json') as f:
data = json.loads(f.read())
for field in data:
if field[0:8] == 'tag_Name':
hostname = data[field][0]
ip = data['_meta']['hostvars'][hostname]['ansible_ssh_host']
print(hostname, ip, 'host_vars/{}'.format(hostname))
hostfile = open('host_vars/{}'.format(hostname), 'w')
hostfile.write('ansible_ssh_host: {}\n'.format(ip))
hostfile.close()
f.close()
|