Skip to content

juniper.device.command fails with "Type 'bool' cannot be serialized" on Ansible 2.18.5 #808

@Niklasr69

Description

@Niklasr69

Summary

The juniper.device.command module fails with ConnectionError: Type 'bool' cannot be serialized when using connection: juniper.device.pyez with Ansible 2.17+ for certain commands (particularly clear commands).

Environment

  • Ansible version: 2.18.5
  • juniper.device collection version: 2.0.0
  • Python version: 3.11
  • junos-eznc version: 2.7.6
  • ncclient version: 0.7.0
  • Device: QFX series

Steps to Reproduce

Minimal playbook that reproduces the issue:

---
- name: Test juniper.device bug
  hosts: all
  connection: juniper.device.pyez
  gather_facts: false
  
  tasks:
    - name: This fails with bool serialization error
      juniper.device.command:
        commands:
          - "clear ddos-protection protocols statistics"
          - "clear ddos-protection protocols states"

Run with:

ansible-playbook -k -u <user> test_bug.yml --limit <qfx-device>

Expected Behavior

Commands should execute successfully and return results.

Actual Behavior

Task fails with error:

ansible.module_utils.connection.ConnectionError: Type 'bool' cannot be serialized.

Commands Affected

  • clear commands (confirmed: clear ddos-protection protocols statistics, clear ddos-protection protocols states)
  • Possibly other operational commands that trigger specific RPC code paths
  • Regular show commands appear to work in most cases

Workaround

Add connection: local to the task to bypass the persistent connection:

- name: Clear ddos statistics and state
  juniper.device.command:
    commands:
      - "clear ddos-protection protocols statistics"
      - "clear ddos-protection protocols states"
  connection: local  # Workaround for bool serialization bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions