Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

juniper.device.facts with config_format: "json" with persistent connection juniper.device.pyez fails with ConnectionError: Type 'dict' cannot be serialized.\n" #690

Open
chidanandpujar opened this issue Aug 28, 2024 · 0 comments
Assignees

Comments

@chidanandpujar
Copy link
Collaborator

Issue Type

  • Bug Report

Module Name

juniper.device.facts

juniper.device collection and Python libraries version

(venv) root@masterhost:~/ansible_doc_test/ansible-junos-stdlib/tests# ansible --version
ansible [core 2.17.3]
  config file = /root/ansible_doc_test/ansible-junos-stdlib/tests/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/ansible_doc_test/venv/lib/python3.12/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /root/ansible_doc_test/venv/bin/ansible
  python version = 3.12.0 (main, Aug 27 2024, 22:17:06) [GCC 9.3.0] (/root/ansible_doc_test/venv/bin/python3.12)
  jinja version = 3.1.4
  libyaml = True
(venv) root@masterhost:~/ansible_doc_test/ansible-junos-stdlib/tests# pip freeze
ansible==10.3.0
ansible-core==2.17.3
bcrypt==4.2.0
cffi==1.17.0
colorama==0.4.6
configparser==7.1.0
cryptography==43.0.0
future==1.0.0
icdiff==1.9.1
Jinja2==3.1.4
jsnapy==1.3.8
junos-eznc @ git+https://github.com/Juniper/py-junos-eznc.git@a64698b280fb717730dddf75a2d4d8cacb2e4775
jxmlease==1.0.3
lxml==5.3.0
MarkupSafe==2.1.5
ncclient==0.6.15
packaging==24.1
paramiko==3.4.1
pycparser==2.22
PyNaCl==1.5.0
pyparsing==3.1.4
pyserial==3.5
PyYAML==6.0.2
resolvelib==1.0.1
scp==0.15.0
setuptools==74.0.0
six==1.16.0
transitions==0.9.2
xmltodict==0.13.0
yamlordereddictloader==0.4.2
(venv) root@masterhost:~/ansible_doc_test/ansible-junos-stdlib/tests# 


Summary

juniper.device.facts with config_format: "json" with persistent connection juniper.device.pyez fails with error ansible.module_utils.connection.ConnectionError: Type 'dict' cannot be serialized.\n"

The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-local-39711jk7by9dc/ansible-tmp-1724827191.4637392-39715-113525380193049/AnsiballZ_facts.py", line 107, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-local-39711jk7by9dc/ansible-tmp-1724827191.4637392-39715-113525380193049/AnsiballZ_facts.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-local-39711jk7by9dc/ansible-tmp-1724827191.4637392-39715-113525380193049/AnsiballZ_facts.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.facts', init_globals=dict(_module_fqn='ansible_collections.juniper.device.plugins.modules.facts', _modlib_path=modlib_path),
  File "<frozen runpy>", line 226, in run_module
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/tmp/ansible_juniper.device.facts_payload_2sh9bd_v/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py", line 367, in <module>
  File "/tmp/ansible_juniper.device.facts_payload_2sh9bd_v/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py", line 349, in main
  File "/tmp/ansible_juniper.device.facts_payload_2sh9bd_v/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 1302, in get_configuration
  File "/tmp/ansible_juniper.device.facts_payload_2sh9bd_v/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 1784, in get_config
  File "/tmp/ansible_juniper.device.facts_payload_2sh9bd_v/ansible_juniper.device.facts_payload.zip/ansible/module_utils/connection.py", line 199, in __rpc__
ansible.module_utils.connection.ConnectionError: Type 'dict' cannot be serialized.
fatal: [pyezconnectiontestcases]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-local-39711jk7by9dc/ansible-tmp-1724827191.4637392-39715-113525380193049/AnsiballZ_facts.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-local-39711jk7by9dc/ansible-tmp-1724827191.4637392-39715-113525380193049/AnsiballZ_facts.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-local-39711jk7by9dc/ansible-tmp-1724827191.4637392-39715-113525380193049/AnsiballZ_facts.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.facts', init_globals=dict(_module_fqn='ansible_collections.juniper.device.plugins.modules.facts', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/tmp/ansible_juniper.device.facts_payload_2sh9bd_v/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py\", line 367, in <module>\n  File \"/tmp/ansible_juniper.device.facts_payload_2sh9bd_v/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py\", line 349, in main\n  File \"/tmp/ansible_juniper.device.facts_payload_2sh9bd_v/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 1302, in get_configuration\n  File \"/tmp/ansible_juniper.device.facts_payload_2sh9bd_v/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 1784, in get_config\n  File \"/tmp/ansible_juniper.device.facts_payload_2sh9bd_v/ansible_juniper.device.facts_payload.zip/ansible/module_utils/connection.py\", line 199, in __rpc__\nansible.module_utils.connection.ConnectionError: Type 'dict' cannot be serialized.\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Steps to reproduce


---
- name: Get device facts and configuration
  hosts: all
  connection: local
  gather_facts: no

  tasks:
    - name: Retrieve device facts and configuration and save facts to file
      juniper.device.facts:        
        savedir: "{{ playbook_dir }}"
        config_format: "json"
      register: result

    - name: Print configuration
      debug:
        var: result.ansible_facts.junos.config

PLAY [Get device facts and configuration] *********************************************************************************************************************************

TASK [Retrieve device facts and configuration and save facts to file] *****************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.connection.ConnectionError: Type 'dict' cannot be serialized.
fatal: [pyezconnectiontestcases]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-local-39848jtfuf_9a/ansible-tmp-1724827689.1479154-39852-184082776198465/AnsiballZ_facts.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-local-39848jtfuf_9a/ansible-tmp-1724827689.1479154-39852-184082776198465/AnsiballZ_facts.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-local-39848jtfuf_9a/ansible-tmp-1724827689.1479154-39852-184082776198465/AnsiballZ_facts.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.facts', init_globals=dict(_module_fqn='ansible_collections.juniper.device.plugins.modules.facts', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/tmp/ansible_juniper.device.facts_payload_3t81csub/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py\", line 367, in <module>\n  File \"/tmp/ansible_juniper.device.facts_payload_3t81csub/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py\", line 349, in main\n  File \"/tmp/ansible_juniper.device.facts_payload_3t81csub/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 1302, in get_configuration\n  File \"/tmp/ansible_juniper.device.facts_payload_3t81csub/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 1784, in get_config\n  File \"/tmp/ansible_juniper.device.facts_payload_3t81csub/ansible_juniper.device.facts_payload.zip/ansible/module_utils/connection.py\", line 199, in __rpc__\nansible.module_utils.connection.ConnectionError: Type 'dict' cannot be serialized.\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP ****************************************************************************************************************************************************************
pyezconnectiontestcases    : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   


@Juniper Juniper deleted a comment Aug 28, 2024
@Juniper Juniper deleted a comment Aug 28, 2024
@Juniper Juniper deleted a comment Aug 28, 2024
@Juniper Juniper deleted a comment Aug 28, 2024
@Juniper Juniper deleted a comment Aug 28, 2024
@Juniper Juniper deleted a comment Aug 28, 2024
@Juniper Juniper deleted a comment Aug 28, 2024
@chidanandpujar chidanandpujar changed the title juniper.device.facts with config_format: "json" with persistent connection juniper.device.pyez fails with error ansible.module_utils.connection.ConnectionError: Type 'dict' cannot be serialized.\n" juniper.device.facts with config_format: "json" with persistent connection juniper.device.pyez fails with ConnectionError: Type 'dict' cannot be serialized.\n" Aug 28, 2024
@Juniper Juniper deleted a comment Aug 28, 2024
@Juniper Juniper deleted a comment Aug 28, 2024
@github-staff github-staff deleted a comment Aug 28, 2024
chidanandpujar added a commit to chidanandpujar/ansible-junos-stdlib that referenced this issue Aug 30, 2024
@chidanandpujar chidanandpujar self-assigned this Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@chidanandpujar and others