Skip to content

Commit 9ba597a

Browse files
committed
Fix KeyError on res argument passed to runner_on_ok
Use a more conservative approach as to the existence of the `changed` key. This could be extended to all the keys that are used on dicts passed to the callback (as afaik Ansible doesn't provide any guarantee of their existence), but for now a case-by-case approach may be enough.
1 parent 3f942d2 commit 9ba597a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

datadog_callback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def runner_on_failed(self, host, res, ignore_errors=False):
124124

125125
def runner_on_ok(self, host, res):
126126
# Only send an event when the task has changed on the host
127-
if res['changed']:
127+
if res.get('changed'):
128128
event_text = "$$$\n{0}[{1}]\n$$$\n".format(res['invocation']['module_name'], res['invocation']['module_args'])
129129
self.send_task_event(
130130
'Ansible task changed on "{0}"'.format(host),

0 commit comments

Comments
 (0)