ansible-collections / ibm_zos_core

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

[Bug] [zos_mvs_raw] The first character from each line is missing when using dd_output as stdout #1520

Closed ketankelkar closed 2 weeks ago

ketankelkar commented 1 month ago

Is there an existing issue for this?

Bug description

The first character from each line in content seems to be cut off when dd_output is used. The same behavior does not occur in dd_data_set or dd_unix.

The NPx systems have some extra text configured into their ssh sessions, which makes the problem more apparent:

"dd_names": [
    {
        "byte_count": 257,
        "content": [
            "",
            "ynamic setting of _BPX_SHAREAS IS: REUSE",
            "ynamic setting of _BPX_SPAWN_SCRIPT IS:",
            "ote: /ict zFS set built on Tue Jul 9 17:05:43 EDT 2013",
            "ote: You are running on zOS Release z/OS 05.00 02",
            "hall we play a game? (War Games, 1983)",
            "NPUTRC Set to /etc/inputrc",
            "bcd",
            ""
        ],
        "dd_name": "stdout",
        "name": "KETAN.P4081386.T0912661.C0000000",
        "record_count": 9
    }
],

The output above was a result of the following playbook task:

- name: do stuff
  tags: dd_output
  block:
    - name: mvs raw - echo abcd - output to stdout
      zos_mvs_raw:
        verbose: true
        program_name: bpxbatch
        parm: "SH echo abcd"
        dds:
        - dd_output:
            dd_name: stdout
            return_content:
              type: text
      register: output
    - name: print output
      debug:
        var: output

Here are playbook tasks and output using other types of dds for stdout:

dd_dat_set:

- name: do stuff
  tags: e, dd_data_set
  block:
    - name: create data set for next step
      zos_data_set:
        name: "{{ some_ds }}"
        type: seq
        state: present
    - name: mvs raw - echo abcd - output to dd_data_set
      zos_mvs_raw:
        verbose: true
        program_name: bpxbatch
        parm: "SH echo abcd"
        dds:
        - dd_data_set:
            dd_name: stdout
            data_set_name: "{{ some_ds }}"
      register: output
    - name: retrieve contents of data set.
      command: "dcat {{ some_ds }}"
      register: output
    - name: print output
      debug:
        var: output.stdout_lines
    - name: delete dat set from previous tasks
      zos_data_set:
        name: "{{ some_ds }}"
        state: absent

output when dd_data_set is used for stdout:

TASK [retrieve contents of data set.] *************************************************************************************************************************************************************************************************************************************
changed: [zvm]

TASK [print output] *******************************************************************************************************************************************************************************************************************************************************
ok: [zvm] => {
    "output.stdout_lines": [
        "Dynamic setting of _BPX_SHAREAS IS: NO                                          ",
        "Dynamic setting of _BPX_SPAWN_SCRIPT IS:                                        ",
        "Note: /ict zFS set built on Tue Jul 9 17:05:43 EDT 2013                         ",
        "Note: You are running on zOS Release z/OS 05.00 02                              ",
        "Shall we play a game? (War Games, 1983)                                         ",
        "INPUTRC Set to /etc/inputrc                                                     ",
        "abcd                                                                            "
    ]
}

playbook task usingdd_unix for stdout:

- name: do stuff
  tags: f, dd_unix
  block:
    - name: remove USS file meant for STDOUT
      file: 
        path: "{{ some_file }}"
        state: absent
    - name: mvs raw - uptime - output into unix file.
      zos_mvs_raw:
        program_name: bpxbatch
        parm: "SH echo abcd"
        dds:
        - dd_unix:
            dd_name: stdout
            path: "{{ some_file }}"
            access_group: owronly
            status_group: ['ocreat','otrunc' ]
    - name: retrieve file contents
      command: "cat {{ some_file }}"
      register: output
    - name: print output
      debug:
        var: output.stdout_lines

output when dd_unix is used for stdout:

TASK [retrieve file contents] *********************************************************************************************************************************************************************************************************************************************
changed: [zvm]

TASK [print output] *******************************************************************************************************************************************************************************************************************************************************
ok: [zvm] => {
    "output.stdout_lines": [
        "Dynamic setting of _BPX_SHAREAS IS: REUSE",
        "Dynamic setting of _BPX_SPAWN_SCRIPT IS: YES",
        "Note: /ict zFS set built on Tue Jul 9 17:05:43 EDT 2013",
        "Note: You are running on zOS Release z/OS 05.00 02",
        "Shall we play a game? (War Games, 1983)",
        "INPUTRC Set to /etc/inputrc",
        "abcd"
    ]
}

IBM z/OS Ansible core Version

v1.10.0-beta.1

IBM Z Open Automation Utilities

v1.3.0

IBM Enterprise Python

v3.11.x (default)

ansible-version

v2.16.x (default)

z/OS version

v2.5 (default)

Ansible module

zos_mvs_raw

Playbook verbosity output.

No response

Ansible configuration.

No response

Contents of the inventory

No response

Contents of group_vars or host_vars

No response