Hi Jazzed, I used your example as a base for triggering ansible through a python script, however while the output suggest that the connection to the node is made and the playbook is running, individual steps on the various roles fail consistently in contrast to running the playbook using the ansible-playbook command line tool passing the same playbook.
The output suggests no clear reasons for this behavior. Any ideas on that? Thanks, Dimitris On Monday, 3 November 2014 19:36:35 UTC+1, Jazzed wrote: > > import ansible.runner > import ansible.playbook > from ansible import callbacks > from ansible import utils > > stats = callbacks.AggregateStats() > playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY) > runner_cb = callbacks.PlaybookRunnerCallbacks(stats, > verbose=utils.VERBOSITY) > > > pb = ansible.playbook.PlayBook( > playbook="nseries.yml", > stats=stats, > callbacks=playbook_cb, > runner_callbacks=runner_cb, > check=True > ) > for (play_ds, play_basedir) in zip(pb.playbook, pb.play_basedirs): > import ipdb > ipdb.set_trace() > # Can play around here to see what's going on. > > > pb.run() # This runs the playbook > > > > On Saturday, February 23, 2013 3:24:25 PM UTC-8, Kyle Heath wrote: >> >> I'm new to Ansible... I would like to create a library of playbooks and >> then use ansible's python api to run the playbooks and get the result from >> a larger python script. >> >> I see there is an example <http://ansible.cc/docs/api.html> of how to >> use the ansible.runner.Runner() from python, but that seems to be useful >> for running modules. I would like to run a playbook from a yml file >> (specifying the host, and private_key parameters directly from python). I >> found the playbooks.Playbook() python class, but the constructor requires >> several parameters which I am not sure how to construct... callbacks... >> runner callbacks... etc >> >> Any pointers or any examples of how to use the python API? >> >> Cheers, >> Kyle >> > -- 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/493d4549-d32f-4c6b-bd6c-f49ab7d71e48%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
