ansible-collections / ibm_zos_core

Red Hat Ansible Certified Content for IBM Z
77 stars 44 forks source link

[Bug] [zos_gather_facts] UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 0: invalid start byte #1466

Closed gngrossi closed 5 months ago

gngrossi commented 5 months ago

Is there an existing issue for this?

Bug description

Trying to run a sample playbook. Having the same issue on Python 3.11.5.

IBM z/OS Ansible core Version

v1.9.0

IBM Z Open Automation Utilities

v1.2.5 (default)

IBM Enterprise Python

v3.12.x

ansible-version

v2.16.x (default)

z/OS version

v2.5 (default)

Ansible module

zos_gather_facts

Playbook verbosity output.

bash-4.4$ ansible-playbook gather.yml

PLAY [MA1] *****

TASK [Playbook start] ** ok: [mvs-sysd] => { "msg": "Mon Apr 22 14:25:40 CDT 2024" }

TASK [Gather all z/OS facts] *** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 0: invalid start byte fatal: [mvs-sysd]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"\", line 107, in \n File \"\", line 99, in _ansiballz_main\n File \"\", line 47, in invoke_module\n File \"\", line 226, in run_module\n File \"\", line 98, in _run_module_code\n File \"\", line 88, in _run_code\n File \"/tmp/ansible_zos_gather_facts_payload_84pa7lkk/ansible_zos_gather_facts_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_gather_facts.py\", line 290, in \n File \"/tmp/ansible_zos_gather_facts_payload_84pa7lkk/ansible_zos_gather_facts_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_gather_facts.py\", line 286, in main\n File \"/tmp/ansible_zos_gather_facts_payload_84pa7lkk/ansible_zos_gather_facts_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_gather_facts.py\", line 236, in run_module\nUnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 0: invalid start byte\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP ***** mvs-sysd : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

Ansible configuration.

[defaults]
forks = 25
inventory = ~/playbooks/inventory.yml
host_key_checking = false
remote_port = 2222
timeout = 15
#deprecation_warnings=false

[ssh_connection]
pipelining = true

Contents of the inventory

MA1:
  hosts:
    mvs-sysd:
  vars:
    ansible_user: "@02858"
#

Contents of group_vars or host_vars

ZOAU_HOME:        /hewitt/zopentools/zoau1258
#ZOAU_HOME:        /hewitt/zopentools/zoau1310
#PYZ_HOME:         /hewitt/zopentools/python311/usr/lpp/IBM/cyp/v3r11/pyz
PYZ_HOME:         /hewitt/zopentools/python312/usr/lpp/IBM/cyp/v3r12/pyz

ansible_python_interpreter: "{{PYZ_HOME}}/bin/python3"

environment_vars:
  LIBPATH:        "{{ZOAU_HOME}}/lib:{{PYZ_HOME}}/lib:/lib:/usr/lib:."
  PATH:           "{{ZOAU_HOME}}/bin:{{PYZ_HOME}}/bin:/bin:/usr/sbin:."

  PYTHONSTDINENCODING: cp1047

# not compatible with pip installing the zoau package
# PYTHONPATH:     "{{ZOAU_HOME}}/lib"

# works without it
# LANG: C

  _BPXK_AUTOCVT:  ON
  _CEE_RUNOPTS:   "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
  _TAG_REDIR_IN:  txt
  _TAG_REDIR_OUT: txt
  _TAG_REDIR_ERR: txt
#
ketankelkar commented 5 months ago

Making the following change in the environment_vars seems to have helped me: _BPXK_AUTOCVT: ON --> _BPXK_AUTOCVT: "ON"

Let me know if it works for you!!

From the verbosity log from my recreate:

gngrossi commented 5 months ago

@ketankelkar Yes, it does work...much appreciated. I used the -vvvv and confirmed the values before and after. closing...thanks