I have found that if you want to wrap the running of a playbook inside of a 
python script (so you can make the interface a bit more user friendly and 
translate cmdline args to --extra-vars, etc), the 2.0 API is much simpler.

from ansible.cli.playbook import PlaybookCLI

cliargs = {
    'playbook':pb,
    'args': {
        '-i':host_list,
        '-e':json.dumps(xvars),
    }
}

def _run_playbook_v20(cliargs):
    ansargs=['ansible-playbook',cliargs['playbook']]
    [ansargs.extend([k,v]) for k,v in cliargs['args'].items()]
    print "executing: {}".format(' '.join(ansargs))
    cli = PlaybookCLI(ansargs)
    cli.parse()
    return cli.run()



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6d6e3d1d-193c-40bb-b5a5-2ddf2a355db0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to