Open ddimatos opened 9 months ago
2 work arounds for this issue, one has a 5 second async delay which uses ansyc_status
, while the other with no delay does not use async_status
(more of a submit and forget model).
- hosts: zvm
collections:
- ibm.ibm_zos_core
gather_facts: false
vars:
files:
- file_name : "UPTIME"
- file_name : "hello.jcl"
environment: "{{ environment_vars }}"
tasks:
- name: Copy files from control node to USS
ibm.ibm_zos_core.zos_copy:
src: "{{playbook_dir}}/files/{{ item.file_name }}"
dest: "/tmp/{{ item.file_name }}"
remote_src: false
force: true
register: result
loop: "{{ files }}"
- name: Result
ansible.builtin.debug:
var: result
- name: Use ZOAU jsub to submit jobs asynchronously, place result in async_submit
ansible.builtin.shell: jsub -f "/tmp/{{ item.file_name }}"
register: async_submit
loop: "{{ files }}"
async: 0
poll: 0
- name: Print complete result for async task registered with var async_submit
ansible.builtin.debug:
var: async_submit.results
- name: Loop over the Job IDs and capture them into a var called job
zos_job_output:
job_id: "{{ item.stdout }}"
register: jobs
loop: "{{ async_submit.results }}"
- name: Print all async jobs
ansible.builtin.debug:
var: jobs
and
---
- hosts: zvm
collections:
- ibm.ibm_zos_core
gather_facts: false
vars:
files:
- file_name : "UPTIME"
- file_name : "hello.jcl"
environment: "{{ environment_vars }}"
tasks:
- name: Copy files from control node to USS
ibm.ibm_zos_core.zos_copy:
src: "{{playbook_dir}}/files/{{ item.file_name }}"
dest: "/tmp/{{ item.file_name }}"
remote_src: false
force: true
register: result
loop: "{{ files }}"
- name: Result
ansible.builtin.debug:
var: result
- name: Use ZOAU jsub to submit jobs asynchronously, place result in async_submit
ansible.builtin.shell: jsub -f "/tmp/{{ item.file_name }}"
register: async_submit
loop: "{{ files }}"
async: 5
poll: 0
- name: Print complete result for async task registered with var async_submit
ansible.builtin.debug:
var: async_submit.results
- name: Print the async_submit async ansible_job_id, special var used for async call
ansible.builtin.debug:
msg: "ansible_job_id is --> {{ item.ansible_job_id }}"
loop: "{{ async_submit.results }}"
- name: Monitor when the async jsub completes and capture jsub JCL Batch Job ID, try this up to 10 times
async_status:
jid: "{{ item.ansible_job_id }}"
register: async_result
until: async_result.finished
retries: 10
delay: 10
loop: "{{ async_submit.results }}"
- name: Print the async_result, this should now contain the job ID
ansible.builtin.debug:
var: async_result
- name: Loop over the Job IDs and capture them into a var called job
zos_job_output:
job_id: "{{ item.stdout }}"
register: jobs
loop: "{{ async_result.results }}"
- name: Print all async jobs
ansible.builtin.debug:
var: jobs
My concern is how async
will impact our future work items:
In summary, what we need to determine is:
async
might impact bullets (1) or (2) above
Is there an existing issue for this?
Ansible module
zos_job_submit
Enhancement or feature description
The collection does not explicitly support Ansible
async
, when trying to use it with zos_job_submit the errorasync is not supported for this task
appears. Further evaluation, to supportasync
plugins specifically have to declareself._supports_async = True
but its more than simply this entry, the module itself has to deal with running in the async setting.This epic should have issues created:
self._supports_async = True
and answer the question if our current architecture can support this and if not what needs to change.async
might impact a future enhancement where modulezos_job_submit
could accept a list of jobs to submit , the JSON responses were designed to accommodate more than one job submission, it would be good to understand if such a the multi job submission feature were might be limited byansync
, for example if both async and multiple jobs were supported we might need to disable async when running more than one job else asynchronously looping over a list of jobs might not lend itself to poll.For reference:
An example which I can't fully evaluate because of the error: zos_job_submit_loop_async.yml
submit_jobs.yml
Error:
Related issues: