ansible-collections / ibm_zos_core

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

[Bug] [zos_script] Module does not support multiple command line args #1669

Closed ketankelkar closed 1 month ago

ketankelkar commented 2 months ago

Is there an existing issue for this?

Bug description

The module has a feature which allows for args to be submitted in-line which currently does not read/parse more than the FIRST arg.

- name: Run REXX script to get a job's information.
  ibm.ibm_zos_core.zos_script:
    cmd: "{{ playbook_dir }}/files/JOB_INFO JOBID=JOB00114 OWNER=OMVSADM JOBNAME=HELLO"
    remote_src: false

However, the 2nd and 3rd args (OWNER and JOBNAME) are not successfully parsed, see partial extracts of the verbosity output:

changed: [zos_host] => {
    "changed": true,
    "cmd": "/Users/ketan/dev/z_ansible_collections_samples/zos_concepts/zos_script/files/JOB_INFO JOBID=JOB00114 OWNER=OMVSADM JOBNAME=HELLO",
    "invocation": {
        "module_args": {
            "chdir": null,
            "cmd": "/.ansible/tmp/zos_script.mipsomgr.JOB_INFO JOBID=JOB00114",     <------- missing OWNER/JOBNAME
            "creates": null,
            "executable": null,
            "remote_src": false,
            "removes": null,
            "template_parameters": null,
            "use_template": false
        }
    },
    "rc": 0,
    "remote_cmd": "/.ansible/tmp/zos_script.mipsomgr.JOB_INFO JOBID=JOB00114",     <------- missing OWNER/JOBNAME
    "stderr": "",

Notice the discrepancy between cmd outside the invocation dict and cmd and remote_cmd inside the invocation dict, the two value inside the invocation dict are missing the OWNER and JOBNAME args which were passed in from the playbook.

IBM z/OS Ansible core Version

v1.10.0

IBM Z Open Automation Utilities

v1.3.2

IBM Enterprise Python

v3.11.x (default)

ansible-version

v2.16.x (default)

z/OS version

v2.5 (default)

Ansible module

zos_script

Playbook verbosity output.

The above was recreated from running the sample playbook on the samples repo

First I submitted a job,

Expected output from the recreate is:

changed: [zos_host] => {
    "changed": true,
    "cmd": "/Users/ketan/dev/z_ansible_collections_samples/zos_concepts/zos_script/files/JOB_INFO JOBID=JOB00114 OWNER=OMVSADM JOBNAME=HELLO",
    "invocation": {
        "module_args": {
            "chdir": null,
            "cmd": "/.ansible/tmp/zos_script.mipsomgr.JOB_INFO JOBID=JOB00114",
            "creates": null,
            "executable": null,
            "remote_src": false,
            "removes": null,
            "template_parameters": null,
            "use_template": false
        }
    },
    "rc": 0,
    "remote_cmd": "/.ansible/tmp/zos_script.mipsomgr.JOB_INFO JOBID=JOB00114",
    "stderr": "",
    "stderr_lines": [
        ""
    ],
    "stdout": "-----START OF JOB-----\nposition:1\njob_id:JOB00114..JOBID.1\njob_name:HELLO\nsubsystem:STL1\nsystem:\nowner:OMVSADM\nret_code_msg:CC 0000\nclass:A\ncontent_type:JOB\n-----END OF JOB-----\n",
    "stdout_lines": [
        "-----START OF JOB-----",
        "position:1",
        "job_id:JOB00114..JOBID.1",
        "job_name:HELLO",
        "subsystem:STL1",
        "system:",
        "owner:OMVSADM",
        "ret_code_msg:CC 0000",
        "class:A",
        "content_type:JOB",
        "-----END OF JOB-----",
        ""
    ],
    "tempfile_path": "/.ansible/tmp/zos_script.mipsomgr.JOB_INFO"
}

Ansible configuration.

No response

Contents of the inventory

No response

Contents of group_vars or host_vars

No response

rexemin commented 2 months ago

Thinking the problem arises here: Screenshot 2024-09-03 at 11 10 56

script_args is taking the second item in the array while ignoring that shlex separates each arg into its own item.