Example for running a playbook using Python API

Probably the best example of running a playbook via Python code is
actually /usr/bin/ansible-playbook itself, though it uses nearly all
of the flags.

https://github.com/ansible/ansible/blob/devel/bin/ansible-playbook

Anything referenced there either comes from command line flags or is
constructed further up in that file.

Hope that helps!

Hi all,
I have a Playbook which is used to push template configuration to the router, It work fine if I run command ansible-playbook playbook_name.yml
But now I don’t want call Playbook manually, I want to creat a file (such as pb.run) and then use it to call playbook.
How I can do it?
Please help me, thanks!

Vào 06:37:52 UTC+7 Chủ Nhật, ngày 24 tháng 2 năm 2013, Michael DeHaan đã viết:

Hello Dao,

I did the same in ansible.

  • I created one pb.sh within the file i wrote below

ansible-playbook playbook1.yml

and saved.

  • then i change the permission chmod +x pb.sh and run those as
    [root@localhost]# ./pb.sh

i think it is useful to you also.

Ansible Training In Hyderabad