Skip to content

Commit

Permalink
Delete IncludeRole object from result object for include_role tasks
Browse files Browse the repository at this point in the history
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: ansible/ansible#30385
Change-Id: I5b00d45244f7c90aa4a70171db88e19c94be5a9b
  • Loading branch information
David Moreau-Simard committed Sep 15, 2017
1 parent 490fbf3 commit 6fd7a95
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions ara/plugins/callbacks/log_ara.py
Expand Up @@ -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())
Expand Down
17 changes: 11 additions & 6 deletions ara/tests/integration/include_role.yml
Expand Up @@ -16,15 +16,20 @@
# You should have received a copy of the GNU General Public License
# along with ARA. If not, see <http://www.gnu.org/licenses/>.

- 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

0 comments on commit 6fd7a95

Please sign in to comment.