DataDog / ansible-datadog-callback

Ansible callback to get stats & events directly into Datadog http://datadoghq.com
MIT License
93 stars 47 forks source link

Handle no_log: True and missing invocation key gracefully #7

Closed dkerwin closed 9 years ago

dkerwin commented 9 years ago

Task example for no_log: True. Leads to missing invocation key as well.

- name: create new secret
  shell: openssl rand -base64 32
  register: my_secret
  no_log: true

Value of result:

{'censored': 'results hidden due to no_log parameter', 'changed': True, 'rc': 0}

Cheers :beers:

Daniel

olivielpeau commented 9 years ago

Good stuff, thanks!

Apart from my comment, I think we could avoid duplicating code by factorizing these two blocks: https://github.com/gini/ansible-datadog-callback/blob/fix_no_log_and_invocation_key/datadog_callback.py#L116-L126 and https://github.com/gini/ansible-datadog-callback/blob/fix_no_log_and_invocation_key/datadog_callback.py#L139-L148 into one function (that could take a boolean argument to choose between including and not including the msg in the event_text when all the fields are there).

What do you think?

dkerwin commented 9 years ago

Commit 47c1c58 refactors the event_text generation

olivielpeau commented 9 years ago

Awesome, thanks a lot for your contribution @dkerwin!

Merging this.