From 40894c7027144c4d875e5d5a97e5cfebf75ec318 Mon Sep 17 00:00:00 2001 From: David Moreau Simard Date: Wed, 30 Sep 2020 22:15:55 -0400 Subject: [PATCH] callback: record handler tasks too It turns out that we had been missing out on handler tasks because we need to use the hook "v2_playbook_on_handler_task_start" for those. Fixes: https://github.com/ansible-community/ara/issues/178 Change-Id: Id05ba581fb22eee26270c7f4bccc3445e87b5d3b --- ara/plugins/callback/ara_default.py | 5 +++++ .../roles/smoke-tests/handlers/main.yaml | 7 +++++++ .../roles/smoke-tests/tasks/test-ops.yaml | 13 +++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/integration/roles/smoke-tests/handlers/main.yaml diff --git a/ara/plugins/callback/ara_default.py b/ara/plugins/callback/ara_default.py index 1fd0833b..aa5b04f0 100644 --- a/ara/plugins/callback/ara_default.py +++ b/ara/plugins/callback/ara_default.py @@ -304,6 +304,11 @@ class CallbackModule(CallbackBase): return self.play + def v2_playbook_on_handler_task_start(self, task): + self.log.debug("v2_playbook_on_handler_task_start") + # TODO: Why doesn't `v2_playbook_on_handler_task_start` have is_conditional ? + self.v2_playbook_on_task_start(task, False, handler=True) + def v2_playbook_on_task_start(self, task, is_conditional, handler=False): self.log.debug("v2_playbook_on_task_start") self._end_task() diff --git a/tests/integration/roles/smoke-tests/handlers/main.yaml b/tests/integration/roles/smoke-tests/handlers/main.yaml new file mode 100644 index 00000000..d330befd --- /dev/null +++ b/tests/integration/roles/smoke-tests/handlers/main.yaml @@ -0,0 +1,7 @@ +# Copyright (c) 2020 The ARA Records Ansible authors +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: handler + debug: + msg: hi, this is a handler task + register: _handler_run diff --git a/tests/integration/roles/smoke-tests/tasks/test-ops.yaml b/tests/integration/roles/smoke-tests/tasks/test-ops.yaml index 0f9c75ec..b6d84b3b 100644 --- a/tests/integration/roles/smoke-tests/tasks/test-ops.yaml +++ b/tests/integration/roles/smoke-tests/tasks/test-ops.yaml @@ -49,3 +49,16 @@ - name: Test for XSS command: echo "" changed_when: False + +- name: Notify something for a handler task + command: /bin/true + notify: + - handler + +- name: Flush handlers + meta: flush_handlers + +- name: Assert that handler task has run + assert: + that: + - _handler_run is success