From 6fd7a95ab940d7a78ade0040232a1ffdaf41ccfc Mon Sep 17 00:00:00 2001 From: David Moreau-Simard Date: Thu, 14 Sep 2017 14:59:43 -0600 Subject: [PATCH] Delete IncludeRole object from result object for include_role tasks The IncludeRole object crashes the callback because ARA tries to serialize the result._result dict and result._result['include_role'] is not serializable, it's an IncludeRole class instance. We don't need this key and what is inside so let's just work around the issue by deleting it for now. See: https://github.com/ansible/ansible/issues/30385 Change-Id: I5b00d45244f7c90aa4a70171db88e19c94be5a9b --- ara/plugins/callbacks/log_ara.py | 6 ++++++ ara/tests/integration/include_role.yml | 17 +++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ara/plugins/callbacks/log_ara.py b/ara/plugins/callbacks/log_ara.py index b7419935..5fe38f0c 100644 --- a/ara/plugins/callbacks/log_ara.py +++ b/ara/plugins/callbacks/log_ara.py @@ -150,6 +150,12 @@ def log_task(self, result, status, **kwargs): LOG.debug('logging task result for task %s (%s), host %s', self.task.name, self.task.id, result._host.get_name()) + # An include_role task might end up putting an IncludeRole object + # inside the result object which we don't need + # https://github.com/ansible/ansible/issues/30385 + if 'include_role' in result._result: + del result._result['include_role'] + result.task_start = self.task.time_start result.task_end = datetime.now() host = self.get_or_create_host(result._host.get_name()) diff --git a/ara/tests/integration/include_role.yml b/ara/tests/integration/include_role.yml index 9b253ad7..f3dbd027 100644 --- a/ara/tests/integration/include_role.yml +++ b/ara/tests/integration/include_role.yml @@ -16,15 +16,20 @@ # You should have received a copy of the GNU General Public License # along with ARA. If not, see . -- name: "Ansible >=2.2: include_role tasks" +# Tests for https://github.com/ansible/ansible/issues/30385 +- name: Test include role without static hosts: localhost gather_facts: no tasks: - - name: Include a role + - name: Include role without static include_role: - name: "included-role" + name: included-role - - name: Include tasks from a role +- name: Test include role with static + hosts: localhost + gather_facts: no + tasks: + - name: Include role with static include_role: - name: "included-role" - tasks_from: "included-task" + name: included-role + static: no