Ansible tower to AWX migration - inventories, templates, hosts

Viewed 31

I am working on a migration task ie migrate from ansible tower to awx. My focus is to export inventories, hosts projects and job templates. What I did to get started is to use a python script to export all inventories etc to json file. Sample code to fetch all inventories from all pages and save it to json file is as follows:

inventoryReponse = []
r = requests.get('{}/api/v2/inventories/'.format(args.url), auth=HTTPBasicAuth(args.username, args.password)).json()
inventoryReponse.extend(r['results'])
next_page = r['next']

while next_page != None:
    res = requests.get('{}{}'.format(args.url, next_page), auth=HTTPBasicAuth(args.username, args.password)).json()
    inventoryReponse.extend(res['results'])
    # print(next_page, res)
    next_page = res['next']

filepath = '/Users/username/AWX/exported_inventories.json'
with open(filepath, 'w', encoding='utf-8') as f:
    json.dump(inventoryReponse, f, ensure_ascii=False, indent=4)

In the same way I export hosts, projects and job_templates from my ansible tower. Now I am stuck on how to migrate/import this json data to my AWX. Am I on correct path or is there any other way to migrate inventories etc from Ansible tower to AWX? Any other information on ansible tower to AWX migration will be really helpful. Thanks

0 Answers
Related