Thanks Jazzed,

Its working fine only if I have my host listed in /etc/ansible/hosts, but I 
want to pass my custom host file while running a playbook. Can you tell me 
how to do so?


On Tuesday, November 4, 2014 at 12:06:35 AM UTC+5:30, 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/99dfcb3e-afe2-44d3-a3b4-5bf65bda1ecb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to