here is my code it i don’t know if I’m on the right track
tasks:
- name: Submit a long running PDS job and wait up to 30 seconds for completion.
zos_job_submit:
# src: SYS2.DR.VERIFY.JCL(TESTANS)
src: XXC91.JCL.CNTL(TEST1)
location: DATA_SET
wait_time_s: 10
**CAENF is active on T001 S0192669 Initialization Verified **
**CCISSLGW is active on T001 S0192845 Initialization Verified **
**DATACOM is active on T001 S0192601 Initialization Verified **
**CA11 is active on T001 S0192834 Initialization Verified ** CA11DB is active on T001 S0192600 Initialization Verified
Ignore for now that fact that the last time I touched JCL or JES, z/os wasn’t called z/os and most of the Ansible core team wasn’t born yet…
Could you back up a step and try to explain how you see this working? I’ve been reading your initial post a few times and can’t quite make the pieces fit into a story.
For example: “{{ d_symbol_output }}”. I’m not sure what the contents of that file is supposed to look like. At any rate, what you show below that doesn’t match the regexp: from your “Search for string” task. Worse, lineinfile doesn’t count lines that match a pattern. It changes at most one (of possibly many) matching lines, or in case none of the existing lines matches it appends the specified line: to the file. Somehow I don’t think that’s what you have in mind.
I’m not asking you to give us a tutorial on z/os; that’s clearly out of scope for this forum. But perhaps if you can explain what you have to work with and what you’re trying to achieve, we may be able to give some hints about how to get there with Ansible.
i simplify the code to work it found
“msg”: “CAENF is active on T001” active
i dont know if this the best way to code this and how to find the other task in this list.
in the below systprt it show 5 acitive task
i’m trying to capture all 5 task in the systprt
the logic is if this systprt show any else then active then do something.
**CAENF is active on T001 S0192669 Initialization Verified **
**CCISSLGW is active on T001 S0192845 Initialization Verified **
**DATACOM is active on T001 S0192601 Initialization Verified **
**CA11 is active on T001 S0192834 Initialization Verified **
name: Submit a long running PDS job and wait up to 30 seconds for completion.
zos_job_submit:
name: Print Displaying system activity to logs
ansible.builtin.debug:
msg: “{{ display_output }}”
msg: "{{ display_output | regex_search('CAENF is active on T001') }}"
TASK [Print Displaying system activity to logs] ********************************
task path: /runner/project/zos-display-stuff.yml:26
ok: [smtsftp.dtcc.com] => {
“msg”: “CAENF is active on T001”
}
Your last post - prior to editing - showed the structure of display_output, from which I could construct the following tasks. They should show you how to determine the number of “is active on” lines in display_output’s SYSTSPRT DD.
- name: Select SYSTSPRT 'is active on' lines
ansible.builtin.set_fact:
is_active_on: "{{ display_output.jobs[0].ddnames
| selectattr('ddname','eq','SYSTSPRT')
| map(attribute='content')
| map('select', 'match', '.* is active on ')
| flatten
}}"
- name: Show the 'is active on' lines, and count them
ansible.builtin.debug:
msg:
- "{{ is_active_on }}"
- "{{ is_active_on | length }}"
(I haven’t seen “IEF” messages since December of 1996. [shivers])