Hi Ritesh,

Sorry for the late response.  As this is a development question, can you
please post this on ansible-devel?

Thanks!



On Wed, Nov 26, 2014 at 3:33 PM, Ritesh Shetty <[email protected]>
wrote:

> Hi All,
> My application trigger the playbook using the python api. Now since there
> are many tasks and each might take a long time, i need to keep the user
> informed of what is going on. So i have create a Job and Tasks table and
> idea is to create the Job before initiating the playbook.run() . Now for me
> to keep updating the state of the tasks i need to implement the callback
> plugin and here i can insert the tasks to the database and keep updating
> the states. Now problem is how do i get the data(my_custom_job_id) i
> defined in the calling code where i ran playbook.run()
>
>
> class CallbackModule(object):
>     """
>     logs playbook results, per host, in /var/log/ansible/hosts
>     """
>
>     def __init__(self):
>         self.stats = {}
>         self.task_id = None
>
>     def on_any(self, *args, **kwargs):
>         pass
>
>     def runner_on_failed(self, host, res, ignore_errors=False):
>         if type(self.task_id) is str:
>             print "Task name "+ self.task.name
>             print "Task id "+self.task_id
>         log(host, 'FAILED', res)
>
>     def runner_on_ok(self, host, res):
>         if type(self.task_id) is str:
>             print "Task name "+ self.task.name
>             print "Task id "+self.task_id
>         log(host, 'OK', res)
>
>     def playbook_on_task_start(self, name, is_conditional):
>         """
>         Logs the start of each task
>         """
> #      HOW DO I GET THE my_custom_job_id WHICH I DEFINED IN MY PYTHON API
> WHERE TO DID A playbook.run()
> #      jobapi.createjob(my_custom_job_id )
>         task_id=str(randint(2,9))
> #     jobapi.addTask(my_custom_job_id, task_id,name)
>         self.task_id = task_id
>
>  --
> 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/a6455abe-5c2e-42ba-919a-d7a99b1181b5%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/a6455abe-5c2e-42ba-919a-d7a99b1181b5%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2BnsWgxGxsz-mA5J5SNpHs0OJDJuN8PDYrbqCq_bMwmNVf1dLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to