ansible-collections / ibm_zos_core

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

[Bug] [zos_copy] When member was in use during copy, incorrect message was returned. #1253

Closed ddimatos closed 3 months ago

ddimatos commented 6 months ago

Is there an existing issue for this?

Are the dependencies a supported version?

IBM Z Open Automation Utilities

v1.2.5

IBM Enterprise Python

v3.11.x

IBM z/OS Ansible core Version

v1.8.0-beta.1

ansible-version

latest

z/OS version

None

Ansible module

zos_copy

Bug description

When the playbook tasks the member TEST1, I then went into ISPF and edited the PDSE and ran again (obtain lock), in this second run, I expected a message that would tell me the data set has a lock on it and to use force_lock if an operation need to be done on a data set held by a long running process. Instead what I received while not invalid, It feels out of sequence. Maybe I should be told first that force_lock needs to be enabled?

fatal: [zvm]: FAILED! => {"changed": false, "message": "", "msg": "DatasetMemberDeleteError('An error occurred during deletion of data set member\"ANSIBLE.TEST.PDS(TEST1)\". RC=1')", "names": ["ANSIBLE.TEST.PDS(TEST1)"]}

I expected:

    - name: Create a PDS data set if it does not exist
      zos_data_set:
        name: ANSIBLE.TEST.PDS
        type: pds
        space_primary: 5
        space_type: M
        record_format: fba
        record_length: 80
        replace: yes
      register: result

    - name: Results
      debug:
        var: result

    - name: Create a MEMBER
      zos_data_set:
        name: ANSIBLE.TEST.PDS(TEST1)
        state: present
        replace: true
        type: MEMBER
      register: result

    - name: Results
      debug:
        var: result

    - name: Copy job from controller to PSDE member
      ibm.ibm_zos_core.zos_copy:
        src: "{{playbook_dir}}/files/TYPRUNSCAN.jcl"
        dest: ANSIBLE.TEST.PDS(TEST1)
        encoding:
          from: UTF-8
          to: IBM-1047
        force: true
      register: result

    - name: Results
      debug:
        var: result
(venv-2.16) ~/git/playbooks $: ansible-playbook -i inventory copy_job_to_dataset_submit.yml --tags "version1"

PLAY [zvm] *************************************************************************************************************************************

TASK [Create a MEMBER] *************************************************************************************************************************
changed: [zvm]

TASK [Results] *********************************************************************************************************************************
ok: [zvm] => {
    "result": {
        "changed": true,
        "failed": false,
        "message": "",
        "names": [
            "ANSIBLE.TEST.PDS(TEST1)"
        ]
    }
}

TASK [Copy job from controller to PSDE member] *************************************************************************************************
changed: [zvm]

TASK [Results] *********************************************************************************************************************************
ok: [zvm] => {
    "result": {
        "changed": true,
        "dest": "ANSIBLE.TEST.PDS(TEST1)",
        "dest_created": true,
        "destination_attributes": {
            "block_size": 32760,
            "record_format": "FBA",
            "record_length": 1028,
            "space_primary": 3,
            "space_secondary": 1,
            "space_type": "K",
            "type": "PO"
        },
        "failed": false,
        "is_binary": false,
        "src": "/Users/ddimatos/git/playbooks/files/TYPRUNSCAN.jcl"
    }
}

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

(venv-2.16) ~/git/playbooks $: ansible-playbook -i inventory copy_job_to_dataset_submit.yml --tags "version1"

PLAY [zvm] *************************************************************************************************************************************

TASK [Create a MEMBER] *************************************************************************************************************************
fatal: [zvm]: FAILED! => {"changed": false, "message": "", "msg": "DatasetMemberDeleteError('An error occurred during deletion of data set member\"ANSIBLE.TEST.PDS(TEST1)\". RC=1')", "names": ["ANSIBLE.TEST.PDS(TEST1)"]}

Playbook verbosity output.

No response

Ansible configuration.

No response

Contents of the inventory

No response

Contents of group_vars or host_vars

No response

ddimatos commented 5 months ago

Relates to issue #1254

rexemin commented 3 months ago

This error message doesn't come from zos_copy but rather from zos_data_set. The issue comes from a call to DataSet.delete_member() which only zos_data_set uses. You can see the task Create a MEMBER is the one failing in your playbook.

Recreating the scenario but skipping the initial zos_data_set tasks gives me the correct error message.