-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples on how to use event_handler and status_handler #1078
Comments
@Kamatam Thanks for reporting this issue. Could you please give us the use case of |
Simplest example - def my_event_handler(data):
# Do something useful here
print(data)
r = ansible_runner.run(
host_pattern='all',
module='ping',
event_handler=my_event_handler,
inventory='virtualbox.yml') |
@Akasurde thank you for the details. My use case is to send the data to http(s) rest endpoint for specific events only instead for every event. For example, send playbook task result's events. Currently http event handler (with runner_http_url) triggers for every event. |
What you are asking for might be a little on the complex side... what @Akasurde showed you is a basic example of how to pass the event handler in... filtering events and sending them along is a little bit more involved. The What you want to do is filter on the event type you are looking for ... we document this a little bit in the AWX architecture documentation: https://github.com/ansible/awx/blob/devel/docs/job_events.md#job-event-relationships Which makes use of Runner behind the scenes. You can modify the existing http plugin to do what you want and use yours instead of the http plugin. |
Fixes: ansible#1078 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Fixes: #1078 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
…dler Fixes: ansible#1078 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
…dler Fixes: ansible#1078 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
I am trying with following python code to run the playbook using ansible_runner and ansible_runner_http but not able to find how to use event_handler and status_handler. Please suggest some example on this
import ansible_runner
from ansible_runner_http.events import event_handler
r = ansible_runner.run(private_data_dir='/tmp/ansible/,
playbook='test1.yml',
event_handler=None)
The text was updated successfully, but these errors were encountered: