Skip to content

submit inline JCL with the zosmf collection is failing #296

Open
@phil34130

Description

i'm` trying to use the zosmf collection to submit a job that i create , using the following example:

`---`
- name: perform various operations with z/OSMF 
  hosts: zxplore
  collections:
    - ibm.ibm_zosmf
    - ibm.ibm_zos_core
  gather_facts: false
  environment:
    "{{ environment_vars }}"

  vars:
    # Version of z/OSMF used to make REST calls
    ZOSMF_VERSION: "1.0"

    # ***************************************************
    #   Variables for invoking z/OSMF REST API services
    # ***************************************************

    # z/OSMF host and port information
    ZOSMF_HOST: xxx
    ZOSMF_PORT: yyy

    # Desired destination folder on target host for holding definition file
    ZOSMF_DEST_FOLDER: /z/z04683

    # Credentials to access z/OSMF
    ZOSMF_USER: zzz
    ZOSMF_PASS: www


  tasks:
    - name: Create and submit a job
      uri:
        url: https://{{ ZOSMF_HOST }}:{{ ZOSMF_PORT }}/zosmf/restjobs/jobs/
        user: "{{ ZOSMF_USER }}"
        password: "{{ ZOSMF_PASS }}"
        method: PUT
        body_format: json
        body:
          file: "{{lookup('file', '{{ playbook_dir }}/files/HELLO.jcl') }}"  
#          file: //'Z04683.JCL(LISTDS)'
        headers:
          Content-Type: text/plain
          X-CSRF-ZOSMF-HEADER: required_header
        force_basic_auth: true
        validate_certs: false
        status_code: 201
        return_content: true
      register: zosmf_result

    - name: Response dslist {{ ZOSMF_HLQ }} 
      ansible.builtin.debug:
        msg: "{{ zosmf_result }}"

The file HELLO.jcl contains the JCL that i want to submit:
//******************************************************************************
//* Copyright (c) IBM Corporation 2020
//******************************************************************************
//******************************************************************************
//* Configure the job card as needed, most common keyword parameters often
//* needing editing are:
//* CLASS: Used to achieve a balance between different types of jobs and avoid
//*        contention between jobs that use the same resources.
//* MSGLEVEL: controls hpw the allocation messages and termination messages are
//*           printed in the job's output listing (SYSOUT).
//* MSGCLASS: assign an output class for your output listing (SYSOUT)
//*
//* Notes:
//*   If you change the job name, you must update the playbook job name
//*   references.
//******************************************************************************
//HELLO    JOB (T043JM,JM00,1,0,0,0),'HELLO WORLD - JRM',
//             MSGCLASS=X,MSGLEVEL=1,NOTIFY=&SYSUID
//*
//* PRINT "HELLO WORLD" ON JOB OUTPUT
//*
//* NOTE THAT THE EXCLAMATION POINT IS INVALID EBCDIC FOR JCL
//*   AND WILL CAUSE A JCL ERROR
//*
//STEP0001 EXEC PGM=IEBGENER
//SYSIN    DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT1   DD *
HELLO, philippe
/*
//SYSUT2   DD SYSOUT=*
//
when i run the playbook i get the following error (because end of lines are not interpreted)

gitpod /workspace/GSEUK22_ansible101 (main) $ ansible-playbook -i inventory.yaml zosmf_submit_job.yaml

PLAY [perform various operations with z/OSMF] ******************************************************************************************************************

TASK [Create and submit a job] *********************************************************************************************************************************
fatal: [zxplore]: FAILED! => {"changed": false, "connection": "Close", "content": "{\"rc\":4,\"reason\":9,\"category\":6,\"message\":\"Job submission error. Record length 1353 too long for JCL submission, maxlen=80\"}", "content_language": "en-US", "content_type": "application/json", "date": "Thu, 26 Dec 2024 18:05:40 GMT", "elapsed": 0, "json": {"category": 6, "message": "Job submission error. Record length 1353 too long for JCL submission, maxlen=80", "rc": 4, "reason": 9}, "msg": "Status code was 400 and not [201]: HTTP Error 400: Bad Request", "redirected": false, "status": 400, "strict_transport_security": "max-age=31536000; includeSubDomains", "transfer_encoding": "chunked", "url": `"https://204.90.115.200:10443/zosmf/restjobs/jobs/"}`

Any idea how i could solve this ?
i have the same issue if i put the plain text of the JCL in the body
Thanks for any help

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions