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

[Bug] community shell module returns garbage in a call to dls if pipeling is disabled for ibm pyz3.10+ #775

Closed
2 tasks done
ketankelkar opened this issue May 19, 2023 · 4 comments
Assignees
Labels
Bug Something isn't working as designed. In Plan Issue has been accepted put into a planned release

Comments

@ketankelkar
Copy link
Collaborator

ketankelkar commented May 19, 2023

Is there an existing issue for this?

  • There are no existing issues.

Are the dependencies a supported version?

  • The dependencies are supported.

IBM Z Open Automation Utilities

v1.2.2

IBM Enterprise Python

v3.10.x

IBM z/OS Ansible core Version

v1.5.0

ansible-version

v2.11.x

z/OS version

v2.4

Ansible module

No response

Bug description

This is potentially related to an ongoing investigative issue around new python (3.10+) behavior with how binary streams/files are treated. Attached in the zip file is the playbook where the issue was originally found. Seems like it may be a result of the shell module having issues with getting the right encoding down (similar to the behavior of the community lineinfile and blockinfile modules in the linked issue). Where the behavior differs is that for this playbook, turning ON pipelining seems to make it work alright whereas turning OFF pipelining is where the command fails.

Contents of the playbook, see verbosity output section for results:

---
- hosts: zos_host
  gather_facts: no
  vars:
    ansible_ssh_pipelining: no

  environment: "{{ environment_vars }}"
  tasks:

    - name: check if ds exists.
      shell: dls IMSTEST.CICS220.QFIXLIB1
      register: output
      ignore_errors: yes

    - name: check if ds1 exists.
      shell: dls AMSTEST.CICS220.QFIXLIB1
      register: output1
      ignore_errors: yes

Playbook verbosity output.

ansible-playbook [core 2.11.12] 
  config file = /Users/ketan/dev/ansible4pyz/dsexist/ansible.cfg
  configured module search path = ['/Users/ketan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/ketan/venvs/3.9/ansible-2.11/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/ketan/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/ketan/venvs/3.9/ansible-2.11/bin/ansible-playbook
  python version = 3.9.13 (main, Jul 29 2022, 20:13:40) [Clang 13.1.6 (clang-1316.0.21.2.5)]
  jinja version = 3.1.2
  libyaml = True
Using /Users/ketan/dev/ansible4pyz/dsexist/ansible.cfg as config file
host_list declined parsing /Users/ketan/dev/ansible4pyz/inventories/pyz3.11/inventory.yml as it did not pass its verify_file() method
script declined parsing /Users/ketan/dev/ansible4pyz/inventories/pyz3.11/inventory.yml as it did not pass its verify_file() method
Parsed /Users/ketan/dev/ansible4pyz/inventories/pyz3.11/inventory.yml inventory source with yaml plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: ds-exist.yml ***********************************************************************************************************************************************
1 plays in ds-exist.yml

PLAY [zos_host] ******************************************************************************************************************************************************
META: ran handlers

TASK [check if ds exists.] *******************************************************************************************************************************************
task path: /Users/ketan/dev/ansible4pyz/dsexist/ds-exist.yml:20
<ec33022a.vmec.svl.ibm.com> ESTABLISH SSH CONNECTION FOR USER: omvsadm
<ec33022a.vmec.svl.ibm.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' ec33022a.vmec.svl.ibm.com '/bin/sh -c '"'"'echo ~omvsadm && sleep 0'"'"''
<ec33022a.vmec.svl.ibm.com> (0, b'/\n', b'')
<ec33022a.vmec.svl.ibm.com> ESTABLISH SSH CONNECTION FOR USER: omvsadm
<ec33022a.vmec.svl.ibm.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' ec33022a.vmec.svl.ibm.com '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /.ansible/tmp `"&& mkdir "` echo /.ansible/tmp/ansible-tmp-1684520479.409409-24732-144172583930464 `" && echo ansible-tmp-1684520479.409409-24732-144172583930464="` echo /.ansible/tmp/ansible-tmp-1684520479.409409-24732-144172583930464 `" ) && sleep 0'"'"''
<ec33022a.vmec.svl.ibm.com> (0, b'ansible-tmp-1684520479.409409-24732-144172583930464=/.ansible/tmp/ansible-tmp-1684520479.409409-24732-144172583930464\n', b'')
Using module file /Users/ketan/venvs/3.9/ansible-2.11/lib/python3.9/site-packages/ansible/modules/command.py
<ec33022a.vmec.svl.ibm.com> PUT /Users/ketan/.ansible/tmp/ansible-local-247290m8jeb32/tmpq_qsuayk TO /.ansible/tmp/ansible-tmp-1684520479.409409-24732-144172583930464/AnsiballZ_command.py
<ec33022a.vmec.svl.ibm.com> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' '[ec33022a.vmec.svl.ibm.com]'
<ec33022a.vmec.svl.ibm.com> (0, b'sftp> put /Users/ketan/.ansible/tmp/ansible-local-247290m8jeb32/tmpq_qsuayk /.ansible/tmp/ansible-tmp-1684520479.409409-24732-144172583930464/AnsiballZ_command.py\n', b'')
<ec33022a.vmec.svl.ibm.com> ESTABLISH SSH CONNECTION FOR USER: omvsadm
<ec33022a.vmec.svl.ibm.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' ec33022a.vmec.svl.ibm.com '/bin/sh -c '"'"'chmod u+x /.ansible/tmp/ansible-tmp-1684520479.409409-24732-144172583930464/ /.ansible/tmp/ansible-tmp-1684520479.409409-24732-144172583930464/AnsiballZ_command.py && sleep 0'"'"''
<ec33022a.vmec.svl.ibm.com> (0, b'', b'')
<ec33022a.vmec.svl.ibm.com> ESTABLISH SSH CONNECTION FOR USER: omvsadm
<ec33022a.vmec.svl.ibm.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' -tt ec33022a.vmec.svl.ibm.com '/bin/sh -c '"'"'_BPXK_AUTOCVT=ON ZOAU_HOME=/zoau/v1.2.2 PYTHONPATH=/zoau/v1.2.2/lib LIBPATH=/zoau/v1.2.2/lib:/allpython/3.11/usr/lpp/IBM/cyp/v3r11/pyz/lib:/lib:/usr/lib:. PATH=/zoau/v1.2.2/bin:/allpython/3.11/usr/lpp/IBM/cyp/v3r11/pyz/bin:/bin:/var/bin _CEE_RUNOPTS='"'"'"'"'"'"'"'"'FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)'"'"'"'"'"'"'"'"' _TAG_REDIR_ERR=txt _TAG_REDIR_IN=txt _TAG_REDIR_OUT=txt LANG=C PYTHONSTDINENCODING=cp1047 /allpython/3.11/usr/lpp/IBM/cyp/v3r11/pyz/bin/python3 /.ansible/tmp/ansible-tmp-1684520479.409409-24732-144172583930464/AnsiballZ_command.py && sleep 0'"'"''
<ec33022a.vmec.svl.ibm.com> (0, b"\x8e#\x82\xc4\xc7/>\xc5\xc1\xc0\x82\x9a\x80\xc8\xca\xcd\xc1\x8c\x80\x82\xcb\xc8\xc0?\xcd\xc8\x82\x9a\x80\x82\xf1(\xeb\xe8\xe1\xeb\xe8\x06\xe4\xf1\xe4\xeb\x16\x16\x90\x06\xe9\xe3\xf1\xec<\xf1\xe2\x91\x82\x8c\x80\x82\xcb\xc8\xc0\xc1\xca\xca\x82\x9a\x80\x82\x82\x8c\x80\x82\xca\xc4\x82\x9a\x80\x90\x8c\x80\x82\xc4_\xc0\x82\x9a\x80\x82\xc0%\xcb\x80\xf1(\xeb\xe8\xe1\xeb\xe8\x06\xe4\xf1\xe4\xeb\x16\x16\x90\x06\xe9\xe3\xf1\xec<\xf1\xe2\x91\x82\x8c\x80\x82\xcb\xc8/\xca\xc8\x82\x9a\x80\x82\x16\x90\x16\x93\x05\x90\x95\x05\x91\x99\x80\x91\x98\x9a\x16\x91\x9a\x16\x93\x06\x91\x96\x04\x91\x04\x98\x82\x8c\x80\x82\xc1>\xc0\x82\x9a\x80\x82\x16\x90\x16\x93\x05\x90\x95\x05\x91\x99\x80\x91\x98\x9a\x16\x91\x9a\x16\x94\x06\x04\x90\x98\x93\x94\x93\x82\x8c\x80\x82\xc0\xc1%\xc8/\x82\x9a\x80\x82\x90\x9a\x90\x90\x9a\x90\x91\x06\x95\x94\x91\x91\x96\x95\x82\x8c\x80\x82_\xcb\xc5\x82\x9a\x80\x82\x82\x8c\x80\x82\xd1>\xce?\xc4/\xc8\xd1?>\x82\x9a\x80#\x82_?\xc0\xcd%\xc1^/\xca\xc5\xcb\x82\x9a\x80#\x82^\xca/\xcf^\xf8/\xca/_\xcb\x82\x9a\x80\x82\xc0%\xcb\x80\xf1(\xeb\xe8\xe1\xeb\xe8\x06\xe4\xf1\xe4\xeb\x16\x16\x90\x06\xe9\xe3\xf1\xec<\xf1\xe2\x91\x82\x8c\x80\x82^\xcd\xcb\xc1\xcb^\xcb\xc7\xc1%%\x82\x9a\x80\xc8\xca\xcd\xc1\x8c\x80\x82\xcf/\xca>\x82\x9a\x80\xc3/%\xcb\xc1\x8c\x80\x82\xcb\xc8\xc0\xd1>^/\xc0\xc0^>\xc1\xcf%\xd1>\xc1\x82\x9a\x80\xc8\xca\xcd\xc1\x8c\x80\x82\xcb\xc8\xca\xd1\xf8^\xc1_\xf8\xc8`^\xc1>\xc0\xcb\x82\x9a\x80\xc8\xca\xcd\xc1\x8c\x80\x82/\xca\xc5\xce\x82\x9a\x80>\xcd%%\x8c\x80\x82\xc4\xc7\xc0\xd1\xca\x82\x9a\x80>\xcd%%\x8c\x80\x82\xc1\xcc\xc1\xc4\xcd\xc8/\xc2%\xc1\x82\x9a\x80>\xcd%%\x8c\x80\x82\xc4\xca\xc1/\xc8\xc1\xcb\x82\x9a\x80>\xcd%%\x8c\x80\x82\xca\xc1_?\xce\xc1\xcb\x82\x9a\x80>\xcd%%\x8c\x80\x82\xcb\xc8\xc0\xd1>\x82\x9a\x80>\xcd%%'''\x8e", b'Shared connection to ec33022a.vmec.svl.ibm.com closed.\r\n')
<ec33022a.vmec.svl.ibm.com> ESTABLISH SSH CONNECTION FOR USER: omvsadm
<ec33022a.vmec.svl.ibm.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' ec33022a.vmec.svl.ibm.com '/bin/sh -c '"'"'rm -f -r /.ansible/tmp/ansible-tmp-1684520479.409409-24732-144172583930464/ > /dev/null 2>&1 && sleep 0'"'"''
<ec33022a.vmec.svl.ibm.com> (0, b'', b'')
fatal: [zos_host]: FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to ec33022a.vmec.svl.ibm.com closed.\r\n",
    "module_stdout": "�#���/>����������������?�Ȃ����(�����\u0006����\u0016\u0016�\u0006����<�⑂��������ʂ��������Ă�������_������%ˀ�(�����\u0006����\u0016\u0016�\u0006����<�⑂�����/�Ȃ���\u0016�\u0016�\u0005��\u0005������\u0016��\u0016�\u0006��\u0004�\u0004������>�����\u0016�\u0016�\u0005��\u0005������\u0016��\u0016�\u0006\u0004�����������%�/�����������\u0006����������_�ł��������>�?�/��?>���#�_?��%�^/��˂��#�^�/�^�/�/_˂����%ˀ�(�����\u0006����\u0016\u0016�\u0006����<�⑂���^����^���%%�����������/�>����/%���������>^/��^>��%�>����������������^�_��`^�>�˂���������/��΂��>�%%�������ʂ��>�%%���������/�%����>�%%������/��˂��>�%%�����_?��˂��>�%%�������>���>�%%'''�",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 0
}
...ignoring

TASK [check if ds1 exists.] ******************************************************************************************************************************************
task path: /Users/ketan/dev/ansible4pyz/dsexist/ds-exist.yml:25
<ec33022a.vmec.svl.ibm.com> ESTABLISH SSH CONNECTION FOR USER: omvsadm
<ec33022a.vmec.svl.ibm.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' ec33022a.vmec.svl.ibm.com '/bin/sh -c '"'"'echo ~omvsadm && sleep 0'"'"''
<ec33022a.vmec.svl.ibm.com> (0, b'/\n', b'')
<ec33022a.vmec.svl.ibm.com> ESTABLISH SSH CONNECTION FOR USER: omvsadm
<ec33022a.vmec.svl.ibm.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' ec33022a.vmec.svl.ibm.com '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /.ansible/tmp `"&& mkdir "` echo /.ansible/tmp/ansible-tmp-1684520485.577993-24745-104977945672201 `" && echo ansible-tmp-1684520485.577993-24745-104977945672201="` echo /.ansible/tmp/ansible-tmp-1684520485.577993-24745-104977945672201 `" ) && sleep 0'"'"''
<ec33022a.vmec.svl.ibm.com> (0, b'ansible-tmp-1684520485.577993-24745-104977945672201=/.ansible/tmp/ansible-tmp-1684520485.577993-24745-104977945672201\n', b'')
Using module file /Users/ketan/venvs/3.9/ansible-2.11/lib/python3.9/site-packages/ansible/modules/command.py
<ec33022a.vmec.svl.ibm.com> PUT /Users/ketan/.ansible/tmp/ansible-local-247290m8jeb32/tmp_imn4ex2 TO /.ansible/tmp/ansible-tmp-1684520485.577993-24745-104977945672201/AnsiballZ_command.py
<ec33022a.vmec.svl.ibm.com> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' '[ec33022a.vmec.svl.ibm.com]'
<ec33022a.vmec.svl.ibm.com> (0, b'sftp> put /Users/ketan/.ansible/tmp/ansible-local-247290m8jeb32/tmp_imn4ex2 /.ansible/tmp/ansible-tmp-1684520485.577993-24745-104977945672201/AnsiballZ_command.py\n', b'')
<ec33022a.vmec.svl.ibm.com> ESTABLISH SSH CONNECTION FOR USER: omvsadm
<ec33022a.vmec.svl.ibm.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' ec33022a.vmec.svl.ibm.com '/bin/sh -c '"'"'chmod u+x /.ansible/tmp/ansible-tmp-1684520485.577993-24745-104977945672201/ /.ansible/tmp/ansible-tmp-1684520485.577993-24745-104977945672201/AnsiballZ_command.py && sleep 0'"'"''
<ec33022a.vmec.svl.ibm.com> (0, b'', b'')
<ec33022a.vmec.svl.ibm.com> ESTABLISH SSH CONNECTION FOR USER: omvsadm
<ec33022a.vmec.svl.ibm.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' -tt ec33022a.vmec.svl.ibm.com '/bin/sh -c '"'"'_BPXK_AUTOCVT=ON ZOAU_HOME=/zoau/v1.2.2 PYTHONPATH=/zoau/v1.2.2/lib LIBPATH=/zoau/v1.2.2/lib:/allpython/3.11/usr/lpp/IBM/cyp/v3r11/pyz/lib:/lib:/usr/lib:. PATH=/zoau/v1.2.2/bin:/allpython/3.11/usr/lpp/IBM/cyp/v3r11/pyz/bin:/bin:/var/bin _CEE_RUNOPTS='"'"'"'"'"'"'"'"'FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)'"'"'"'"'"'"'"'"' _TAG_REDIR_ERR=txt _TAG_REDIR_IN=txt _TAG_REDIR_OUT=txt LANG=C PYTHONSTDINENCODING=cp1047 /allpython/3.11/usr/lpp/IBM/cyp/v3r11/pyz/bin/python3 /.ansible/tmp/ansible-tmp-1684520485.577993-24745-104977945672201/AnsiballZ_command.py && sleep 0'"'"''
<ec33022a.vmec.svl.ibm.com> (1, b"\x8e#\x82\xc4\xc7/>\xc5\xc1\xc0\x82\x9a\x80\xc8\xca\xcd\xc1\x8c\x80\x82\xcb\xc8\xc0?\xcd\xc8\x82\x9a\x80\x82\x82\x8c\x80\x82\xcb\xc8\xc0\xc1\xca\xca\x82\x9a\x80\x82\xe2\xe5\xdf\xeb\xe4\x91\x91\x90\x93\xe1\x80+?\x80\xc0/\xc8/\xcb\xc1\xc8\xcb\x80_/\xc8\xc4\xc7\x80\xf8/\xc8\xc8\xc1\xca>\x9a\x80\xa0(\xeb\xe8\xe1\xeb\xe8\x06\xe4\xf1\xe4\xeb\x16\x16\x90\x06\xe9\xe3\xf1\xec<\xf1\xe2\x91\x06\x82\x8c\x80\x82\xca\xc4\x82\x9a\x80\x91\x8c\x80\x82\xc4_\xc0\x82\x9a\x80\x82\xc0%\xcb\x80\xa0(\xeb\xe8\xe1\xeb\xe8\x06\xe4\xf1\xe4\xeb\x16\x16\x90\x06\xe9\xe3\xf1\xec<\xf1\xe2\x91\x82\x8c\x80\x82\xcb\xc8/\xca\xc8\x82\x9a\x80\x82\x16\x90\x16\x93\x05\x90\x95\x05\x91\x99\x80\x91\x98\x9a\x16\x91\x9a\x16\x98\x06\x95\x95\x96\x93\x95\x94\x82\x8c\x80\x82\xc1>\xc0\x82\x9a\x80\x82\x16\x90\x16\x93\x05\x90\x95\x05\x91\x99\x80\x91\x98\x9a\x16\x91\x9a\x93\x90\x06\x94\x94\x94\x99\x95\x90\x82\x8c\x80\x82\xc0\xc1%\xc8/\x82\x9a\x80\x82\x90\x9a\x90\x90\x9a\x90\x91\x06\x98\x98\x98\x95\x99\x96\x82\x8c\x80\x82\xc3/\xd1%\xc1\xc0\x82\x9a\x80\xc8\xca\xcd\xc1\x8c\x80\x82_\xcb\xc5\x82\x9a\x80\x82>?>\x05:\xc1\xca?\x80\xca\xc1\xc8\xcd\xca>\x80\xc4?\xc0\xc1\x82\x8c\x80\x82\xd1>\xce?\xc4/\xc8\xd1?>\x82\x9a\x80#\x82_?\xc0\xcd%\xc1^/\xca\xc5\xcb\x82\x9a\x80#\x82^\xca/\xcf^\xf8/\xca/_\xcb\x82\x9a\x80\x82\xc0%\xcb\x80\xa0(\xeb\xe8\xe1\xeb\xe8\x06\xe4\xf1\xe4\xeb\x16\x16\x90\x06\xe9\xe3\xf1\xec<\xf1\xe2\x91\x82\x8c\x80\x82^\xcd\xcb\xc1\xcb^\xcb\xc7\xc1%%\x82\x9a\x80\xc8\xca\xcd\xc1\x8c\x80\x82\xcf/\xca>\x82\x9a\x80\xc3/%\xcb\xc1\x8c\x80\x82\xcb\xc8\xc0\xd1>^/\xc0\xc0^>\xc1\xcf%\xd1>\xc1\x82\x9a\x80\xc8\xca\xcd\xc1\x8c\x80\x82\xcb\xc8\xca\xd1\xf8^\xc1_\xf8\xc8`^\xc1>\xc0\xcb\x82\x9a\x80\xc8\xca\xcd\xc1\x8c\x80\x82/\xca\xc5\xce\x82\x9a\x80>\xcd%%\x8c\x80\x82\xc4\xc7\xc0\xd1\xca\x82\x9a\x80>\xcd%%\x8c\x80\x82\xc1\xcc\xc1\xc4\xcd\xc8/\xc2%\xc1\x82\x9a\x80>\xcd%%\x8c\x80\x82\xc4\xca\xc1/\xc8\xc1\xcb\x82\x9a\x80>\xcd%%\x8c\x80\x82\xca\xc1_?\xce\xc1\xcb\x82\x9a\x80>\xcd%%\x8c\x80\x82\xcb\xc8\xc0\xd1>\x82\x9a\x80>\xcd%%'''\x8e", b'Shared connection to ec33022a.vmec.svl.ibm.com closed.\r\n')
<ec33022a.vmec.svl.ibm.com> Failed to connect to the host via ssh: Shared connection to ec33022a.vmec.svl.ibm.com closed.
<ec33022a.vmec.svl.ibm.com> ESTABLISH SSH CONNECTION FOR USER: omvsadm
<ec33022a.vmec.svl.ibm.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="omvsadm"' -o ConnectTimeout=10 -o 'ControlPath="/Users/ketan/.ansible/cp/ef434da8e8"' ec33022a.vmec.svl.ibm.com '/bin/sh -c '"'"'rm -f -r /.ansible/tmp/ansible-tmp-1684520485.577993-24745-104977945672201/ > /dev/null 2>&1 && sleep 0'"'"''
<ec33022a.vmec.svl.ibm.com> (0, b'', b'')
fatal: [zos_host]: FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to ec33022a.vmec.svl.ibm.com closed.\r\n",
    "module_stdout": "�#���/>����������������?�Ȃ������������ʂ�������䑑���+?��/�/���ˀ_/��ǀ�/����>���(�����\u0006����\u0016\u0016�\u0006����<��\u0006�����Ă�������_������%ˀ�(�����\u0006����\u0016\u0016�\u0006����<�⑂�����/�Ȃ���\u0016�\u0016�\u0005��\u0005������\u0016��\u0016�\u0006�����������>�����\u0016�\u0016�\u0005��\u0005������\u0016����\u0006������������%�/�����������\u0006�����������/�%������������_�ł���>?>\u0005:��?������>��?�������>�?�/��?>���#�_?��%�^/��˂��#�^�/�^�/�/_˂����%ˀ�(�����\u0006����\u0016\u0016�\u0006����<�⑂���^����^���%%�����������/�>����/%���������>^/��^>��%�>����������������^�_��`^�>�˂���������/��΂��>�%%�������ʂ��>�%%���������/�%����>�%%������/��˂��>�%%�����_?��˂��>�%%�������>���>�%%'''�",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
...ignoring
META: ran handlers
META: ran handlers

PLAY RECAP ***********************************************************************************************************************************************************
zos_host                   : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=2   

(ansible-2.11) ketan@Ketans-MBP dsexist % ```

### Ansible configuration.

```YAML
ansible.cfg:

[defaults]
forks = 25
action_plugins=~/.ansible/collections/ansible_collections/ibm/ibm_zos_core/plugins/action

note: the vars section of the playbook contains:

  vars:
    # Use the following VAR to enable/disable pipelining. To confirm pipeling is
    #   enabled, you can check the verbose output (-vvv) for the line
    #   "Pipelining is enabled" near the top of each tasks eg:

    # TASK [check if ds exists.] ***********************************************
    # task path: /Users/ketan/dev/ansible4pyz/dsexist/ds-exist.yml:12
    # Using module file /Users/ketan/venvs/3.9/ansible-2.11/lib/python3.9/site-packages/ansible/modules/command.py
    # Pipelining is enabled.
    # ...

    ansible_ssh_pipelining: no


### Contents of the inventory

```YAML
see the attached inventories in the zip file, there is a folder `pyz3.9` for running with ibm python 3.9 and `pyz3.10` for running with ibm python 3.10. Run the playbook with `ansible-playbook -i pyz3.9 ds-exist.yml` or `ansible-playbook -i pyz3.10 ds-exist.yml`.

Contents of group_vars or host_vars

see inventory section above.
@ketankelkar ketankelkar added the Bug Something isn't working as designed. label May 19, 2023
@ketankelkar
Copy link
Collaborator Author

dsexist.zip

@ketankelkar ketankelkar changed the title [Bug] <title> [Bug] community shell module returns garbage in a call to dls if pipeling is disabled for ibm pyz3.10+ May 19, 2023
@ddimatos ddimatos added this to the *[Q3] [2023] Bugs milestone Jul 12, 2023
@ddimatos
Copy link
Collaborator

The concerning point:

TASK [CAT file] ***************************************************************************************************************************************************************************************************************
[DEPRECATION WARNING]: Module "ansible.builtin.command" returned non UTF-8 data in the JSON response. This will become an error in the future. This feature will be removed in version 2.18. Deprecation warnings can be 
disabled by setting deprecation_warnings=False in ansible.cfg.
changed: [ec33022]

@ddimatos ddimatos added the In Plan Issue has been accepted put into a planned release label Jan 3, 2024
@ketankelkar ketankelkar moved this from 📗In plan to 🏗 In progress in IBM Ansible z/OS Core Collection Mar 18, 2024
@ketankelkar ketankelkar moved this from 🏗 In progress to 🔍 Validation in IBM Ansible z/OS Core Collection Mar 20, 2024
@ketankelkar
Copy link
Collaborator Author

It seems like the environment variables _BPXK_AUTOCVT and PYTHONSTDINENCODING are linked to pipelining.

With pipelining enabled:

PYTHONSTDINENCODING=cp1047 PYTHONSTDINENCODING not set
_BPXK_AUTOCVT=ON "SyntaxError: Non-UTF-8 code starting with..."
_BPXK_AUTOCVT=ALL "SyntaxError: Non-UTF-8 code starting with..."

And with pipelining not enabled:

PYTHONSTDINENCODING=cp1047 PYTHONSTDINENCODING not set
_BPXK_AUTOCVT=ON ???
_BPXK_AUTOCVT=ALL

The full output of the ??? from the table looks like:

"module_stdout": "?#?/>???Ȃ?.?+\u0006?+?<?\u0006?낌?ʂ?Ă?_?%ˀ.?+\u0006?+?<?\u0006?낌?/?Ȃ?\u0016?\u0016?\u0005?\u0005\u0016?\u0016?\u0016?\u0006?\u0016?>?\u0016?\u0016?\u0005?\u0005\u0016?\u0016?\u0016?\u0006?\u0016\u0004\u0004?%?/?\u0006?\u0016?_?ł?>???/??>?#?_??%?^/?˂?#?^?/?^?/?/_˂?%ˀ.?+\u0006?+?<?\u0006?낌?^?^?%%?>^/?^>?%?>?^?_?`^?>?˂?/?΂?>?%%?ʂ?>?%%?/?%?>?%%?/?˂?>?%%?_??˂?>?%%?>?>?%%'''?"

Overall, the recommendation would be to enable pipelining with Ansible playbooks (mainly for better performance) in which case the PYTHONSTDINENCODING=cp1047 would need to be properly configured. My preliminary findings suggest that _BPXK_AUTOCVT=ON is generally more reliable than _BPXK_AUTOCVT=ALL.

The above info was gathered by running a playbook with all the different combinations -

Generic playbook task:

  - name: pipelining(<??>) | autocvt(<??>) | pythonstdinencoding(<??>) | 
    tags: 
    vars:
      ansible_pipelining: <??>
    environment:
      _BPXK_AUTOCVT: <??>
      PYTHONSTDINENCODING: <??>
    block:
    - name: "pipelining(<??>) | autocvt(<??>) | pythonstdinencoding(<??>)"
      meta: noop
    - name: check if ds exists.
      shell: "dls {{ DEFAULT_DATA_SET_NAME }}"
      register: output
      ignore_errors: yes
    - name: print
      debug:
        msg:
          - "{{output.stdout if output is defined and output.stdout is defined else ''}}"
          - "{{output.stderr if output is defined and output.stderr is defined else '' }}"

Full playbook:

- name: recreate issue 775
  hosts: zvm
  collections:
    - ibm.ibm_zos_core
  gather_facts: no
  vars:
    PYZ: "<path_to_pyz>"
    ZOAU: "<path_to_zoau>"

    ansible_host: <url>.ibm.com

    ansible_user: KETAN
    ansible_python_interpreter: "{{ PYZ }}/bin/python3"

    DEFAULT_DATA_SET_NAME: "KETAN.ANSIBLE.TESTDS"


  environment:
    _CEE_RUNOPTS: "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    _TAG_REDIR_ERR: "txt"
    _TAG_REDIR_IN: "txt"
    _TAG_REDIR_OUT: "txt"
    LANG: "C"
    ZOAU: "{{ ZOAU }}/bin"
    LIBPATH: "{{ ZOAU }}/lib/:{{ PYZ }}/lib:/lib:/usr/lib:."
    ZOAUTIL_DIR: "{{ ZOAU }}"
    PYTHONPATH: "{{ ZOAU }}/lib"
    PYTHON: "{{ PYZ }}/bin"
    PATH: "{{ ZOAU }}/bin:{{ PYZ }}/bin:/bin:/usr/sbin:/var/bin:."

    TMPHLQ: "KETAN"

  tasks:
  - name: pipelining(NO) | autocvt(ON) | pythonstdinencoding(cp1047) | a
    tags: a
    vars:
      ansible_pipelining: no
    environment:
      _BPXK_AUTOCVT: "ON"
      PYTHONSTDINENCODING: "cp1047"
    block:
    - name: "pipelining(NO) | autocvt(ON) | pythonstdinencoding(cp1047) | a"
      meta: noop
    - name: check if ds exists.
      shell: "dls {{ DEFAULT_DATA_SET_NAME }}"
      register: output
      ignore_errors: yes
    - name: print
      debug:
        msg:
          - "{{output.stdout if output is defined and output.stdout is defined else ''}}"
          - "{{output.stderr if output is defined and output.stderr is defined else '' }}"

  - name: pipelining(NO) | autocvt(ON) | pythonstdinencoding('') | b
    tags: b
    vars:
      ansible_pipelining: no
    environment:
      _BPXK_AUTOCVT: "ON"
      # PYTHONSTDINENCODING: "cp1047"
    block:
    - name: "pipelining(NO) | autocvt(ON) | pythonstdinencoding('') | b"
      meta: noop
    - name: check if ds exists.
      shell: "dls {{ DEFAULT_DATA_SET_NAME }}"
      register: output
      ignore_errors: yes
    - name: print
      debug:
        msg:
          - "{{output.stdout if output is defined and output.stdout is defined else ''}}"
          - "{{output.stderr if output is defined and output.stderr is defined else '' }}"

  - name: pipelining(NO) | autocvt(ALL) | pythonstdinencoding(cp1047) | c
    tags: c
    vars:
      ansible_pipelining: no
    environment:
      _BPXK_AUTOCVT: "ALL"
      PYTHONSTDINENCODING: "cp1047"
    block:
    - name: "pipelining(NO) | autocvt(ALL) | pythonstdinencoding(cp1047) | c"
      meta: noop
    - name: check if ds exists.
      shell: "dls {{ DEFAULT_DATA_SET_NAME }}"
      register: output
      ignore_errors: yes
    - name: print
      debug:
        msg:
          - "{{output.stdout if output is defined and output.stdout is defined else ''}}"
          - "{{output.stderr if output is defined and output.stderr is defined else '' }}"

  - name: pipelining(NO) | autocvt(ALL) | pythonstdinencoding('') | d
    tags: d
    vars:
      ansible_pipelining: no
    environment:
      _BPXK_AUTOCVT: "ALL"
      # PYTHONSTDINENCODING: "cp1047"
    block:
    - name: "pipelining(NO) | autocvt(ALL) | pythonstdinencoding('') | d"
      meta: noop
    - name: check if ds exists.
      shell: "dls {{ DEFAULT_DATA_SET_NAME }}"
      register: output
      ignore_errors: yes
    - name: print
      debug:
        msg:
          - "{{output.stdout if output is defined and output.stdout is defined else ''}}"
          - "{{output.stderr if output is defined and output.stderr is defined else '' }}"


  - name: pipelining(YES) | autocvt(ON) | pythonstdinencoding(cp1047) | e
    tags: e
    vars:
      ansible_pipelining: yes
    environment:
      _BPXK_AUTOCVT: "ON"
      PYTHONSTDINENCODING: "cp1047"
    block:
    - name: "pipelining(YES) | autocvt(ON) | pythonstdinencoding(cp1047) | e"
      meta: noop
    - name: check if ds exists.
      shell: "dls {{ DEFAULT_DATA_SET_NAME }}"
      register: output
      ignore_errors: yes
    - name: print
      debug:
        msg:
          - "{{output.stdout if output is defined and output.stdout is defined else ''}}"
          - "{{output.stderr if output is defined and output.stderr is defined else '' }}"

  - name: pipelining(YES) | autocvt(ON) | pythonstdinencoding('') | f
    tags: f
    vars:
      ansible_pipelining: yes
    environment:
      _BPXK_AUTOCVT: "ON"
      # PYTHONSTDINENCODING: "cp1047"
    block:
    - name: "pipelining(YES) | autocvt(ON) | pythonstdinencoding('') | f"
      meta: noop
    - name: check if ds exists.
      shell: "dls {{ DEFAULT_DATA_SET_NAME }}"
      register: output
      ignore_errors: yes
    - name: print
      debug:
        msg:
          - "{{output.stdout if output is defined and output.stdout is defined else ''}}"
          - "{{output.stderr if output is defined and output.stderr is defined else '' }}"

  - name: pipelining(YES) | autocvt(ALL) | pythonstdinencoding(cp1047) | g
    tags: g
    vars:
      ansible_pipelining: yes
    environment:
      _BPXK_AUTOCVT: "ALL"
      PYTHONSTDINENCODING: "cp1047"
    block:
    - name: "pipelining(YES) | autocvt(ALL) | pythonstdinencoding(cp1047) | g"
      meta: noop
    - name: check if ds exists.
      shell: "dls {{ DEFAULT_DATA_SET_NAME }}"
      register: output
      ignore_errors: yes
    - name: print
      debug:
        msg:
          - "{{output.stdout if output is defined and output.stdout is defined else ''}}"
          - "{{output.stderr if output is defined and output.stderr is defined else '' }}"

  - name: pipelining(YES) | autocvt(ALL) | pythonstdinencoding('') | h
    tags: h
    vars:
      ansible_pipelining: yes
    environment:
      _BPXK_AUTOCVT: "ALL"
      # PYTHONSTDINENCODING: "cp1047"
    block:
    - name: "pipelining(YES) | autocvt(ALL) | pythonstdinencoding('') | h"
      meta: noop
    - name: check if ds exists.
      shell: "dls {{ DEFAULT_DATA_SET_NAME }}"
      register: output
      ignore_errors: yes
    - name: print
      debug:
        msg:
          - "{{output.stdout if output is defined and output.stdout is defined else ''}}"
          - "{{output.stderr if output is defined and output.stderr is defined else '' }}"

@ketankelkar
Copy link
Collaborator Author

This was mainly a research item, the recreate playbook from the above comment plus the insights about the 3 variables mentioned above further clarifies the picture with default encodings on z/OS interface and Ansible community behavior. Closing out this item as there's no more work to be done specifically relating to this item

@ketankelkar ketankelkar moved this from 🔍 Validation to ✅ Done in IBM Ansible z/OS Core Collection Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working as designed. In Plan Issue has been accepted put into a planned release
Projects
Development

No branches or pull requests

3 participants