def get_playbook_res(group_ids, playbook_file): resource = GenResource().gen_group_dict(group_ids) ans = ANSRunner(resource) ans.run_playbook(playbook_file) res = ans.get_playbook_result() return res
def get_playbook_res(group_ids, playbook_file): host_ids = None for group_id in group_ids: inventory_obj = AnsibleInventory.objects.prefetch_related( 'ans_group_hosts').get(id=group_id) hosts = inventory_obj.ans_group_hosts.all() host_ids = [host.id for host in hosts] host_ids = list(set(host_ids)) resource = gen_resource(host_ids, group_ids) ans = ANSRunner(resource) ans.run_playbook(playbook_file) res = ans.get_playbook_result() return res