need some help on JCl output on msglog
my task is to find 4 active devices in the msglog then copy them to file
my problem is i need to know how to that can anyone help me
name: Submit a long running PDS job and wait up to 30 seconds for completion.
zos_job_submit:
src: SYS2.DR.VERIFY.JCL($#JCLCAI)
location: DATA_SET
wait_time_s: 10
Hi,
If I understand correctly, you are asking how to capture a response and parse it for results, your current tasks don’t have a variable registered to capture that output.
My suggestion is you capture the result into a registered variable, print it with a debug task for inspection then begin to drill down into the JSON with the debug task, later use filters like the regex filter to access the details and/or set those to a fact for later use in the playbook.
This does not fully address your inquiry but will get you very close, at least up to the point you need to start filtering.
- name: Convert a local JCL file to IBM-037 and submit the job
zos_job_submit:
src: "{{playbook_dir}}/files/HELLO.jcl"
location: LOCAL
wait: false
encoding:
from: ISO8859-1
to: IBM-037
register: job_sub_result_production
- name: Set fact `job_sub_result` with live production content
set_fact:
job_sub_result: "{{job_sub_result_production}}"
- name: Set facts used in this playbook
set_fact:
submit_job_name: "{{ job_sub_result.jobs[0].job_name }}"
submit_job_id: "{{ job_sub_result.jobs[0].job_id }}"
submit_jobs_ddnames_length: "{{ job_sub_result.jobs[0].ddnames |length }}"
submit_job_ddnames_list: "{{ job_sub_result.jobs[0].ddnames }}"
submit_job_list: "{{ job_sub_result.jobs[0] }}"
- name: Print values used in this playbook
debug:
msg:
- Job name={{submit_job_name}}
- Job ID={{submit_job_id}}
- DD Count={{submit_jobs_ddnames_length}}
- "{{submit_job_ddnames_list}}"
- "{{submit_job_list}}"
Please use the zos tag when creating z/OS related posts it will help ensure awareness.
Please review the playbook I created here, I have not run it in a few years but should still work just fine; the playbook is designed to help you parse z/OS batch job results ‘offline’ meaning there is static content from a real job submission embedded in the playbook you can keep reusing and then tweak the playbook task to achieve your result without ever having to run a job on z/OS (eg mock playbook development).
You are welcome to grab development builds and try them out if you have ZOAU 1.3.0 or later, for example watch the this specific GDG/Special char support issue, [Enabler] [zos_job_submit] GDG/GDS and special character support · Issue #1375 · ansible-collections/ibm_zos_core · GitHub when its done, grab a development build and test only zos_job_submit; you can do that with this simple command: ansible-galaxy collection install git+https://github.com/ansible-collections/ibm_zos_core.git,dev
The work around uses the community modules and ZOAU directly, not all ZOAU member operations are successful when using special chars, $ @ , etc, dcp works fine.
Steps:
Copy file from controller (assuming the file is on the controller else use remote_src:true to z/OS USS, this will be copied as what ever encoding it starts out with, likely UTF-8
Covert it from the source encoding (UTF-8) to desired encoding (likely IBM-1047) using z/OS USS iconv
Copy it from z/OS USS to a data set member with a special char.
Submit it using ZOAU jsub
Extract the JOB ID
Get the JOB output
hosts: zvm
collections:
ibm.ibm_zos_core
gather_facts: no
environment: “{{ environment_vars }}”
vars:
Original file on control node
org_file: “{{playbook_dir}}/files/hello.jcl”
Transferred file in as UTF8
utf_8_file: ‘/tmp/jcl-utf8.txt’
Converted file resulting from ‘iconv’
ibm_1047_file: ‘/tmp/jcl-1047.txt’
PDSE(member) with a special char escaped
pdse_member: ‘IMSTESTL.DIMATO.JCLCOPY(JCL$MEM)’
tasks:
name: Copy “{{ org_file }}” from controller to USS “{{ utf_8_file }}”
ansible.builtin.copy:
src: “{{ org_file }}”
dest: “{{ utf_8_file }}”
register: result
name: Result
ansible.builtin.debug:
var: result
name: Convert file “{{ utf_8_file }}” from UTF-8 to ibm-1047 at location “{{ ibm_1047_file }}”
shell: “iconv -f UTF-8 -t IBM-1047 {{ utf_8_file }}>{{ ibm_1047_file }}”
register: result
name: Result
ansible.builtin.debug:
var: result
name: Use ZOAU dcp to copy IBM-1047 file “{{ ibm_1047_file }}” into data set “{{ pdse_member }}”
ansible.builtin.shell: dcp “{{ ibm_1047_file }}” “{{ pdse_member }}”
register: result
name: Result
ansible.builtin.debug:
var: result
name: Use ZOAU jsub to submit “{{ pdse_member }}”
ansible.builtin.shell: jsub “{{ pdse_member }}”
register: result
name: Result
ansible.builtin.debug:
var: result
name: Set Job ID variable for reuse.
ansible.builtin.set_fact:
job_id: “{{ result.stdout }}”
name: Get the Job output
zos_job_output:
job_id: “{{ job_id }}”
register: result