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
This commit is contained in:
David Moreau-Simard 2017-09-14 14:59:43 -06:00
parent 490fbf3423
commit 6fd7a95ab9
No known key found for this signature in database
GPG Key ID: FF8D2155E605D693
2 changed files with 17 additions and 6 deletions

View File

@ -150,6 +150,12 @@ class CallbackModule(CallbackBase):
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())

View File

@ -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