Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] [zos_script] Implement async support for zos_script #1878

Open
1 of 4 tasks
fernandofloresg opened this issue Jan 17, 2025 · 0 comments
Open
1 of 4 tasks
Assignees
Labels
Enhancement Enhancement to existing collection content Post plan issue Added to a quarter after planning wsa completed, thus unaplanned.

Comments

@fernandofloresg
Copy link
Collaborator

fernandofloresg commented Jan 17, 2025

Is there an existing issue for this?

  • There are no existing issues.

Enhancement or feature description

Goal of this task is to implement async support for zos_script.

  • Update docs to mention async support.
  • Validate with a playbook.
  • Create a test case.

Ivan already implemented this in zos_job_submit, you can check his PR [here](#1786).

Review [async docs](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_async.html).

Ansible module

zos_script

This is the sample playbook used for zos_job_submit :

demo.yml

---
- hosts: zvm
  collections:
    - ibm.ibm_zos_core
  gather_facts: no
  ignore_errors: true
  vars:
    ZOAU: "/zoau/v1.3.3"
    PYZ: "/allpython/3.11-3/usr/lpp/IBM/cyp/v3r11/pyz"

    job_outputs:

  environment:
    _BPXK_AUTOCVT: "ON"
    ZOAU_HOME: "{{ ZOAU }}"
    PYTHONPATH: "{{ ZOAU }}/lib/3.11"
    LIBPATH: "{{ ZOAU }}/lib:{{ PYZ }}/lib:/lib:/usr/lib:."
    PATH: "{{ ZOAU }}/bin:{{ PYZ }}/bin:/bin:/var/bin"
    _CEE_RUNOPTS: "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    _TAG_REDIR_ERR: "txt"
    _TAG_REDIR_IN: "txt"
    _TAG_REDIR_OUT: "txt"
    LANG: "C"
    PYTHONSTDINENCODING: "cp1047"

  tasks:
    - name: Submit multiple jobs asynchronously.
      ibm.ibm_zos_core.zos_job_submit:
        src: "{{ item }}.jcl"
        location: local
      loop:
        - job_1
        - job_2
        - job_3
      async: 45
      poll: 0
      register: job_submit

    # Use this task to query everything together in a single loop.
    # Doesn't allow to save individual job IDs though!
    # - name: Query async tasks in a loop.
    #   async_status:
    #     jid: "{{ item.ansible_job_id }}"
    #   register: current_job
    #   until: current_job.finished
    #   retries: 10
    #   loop: "{{ job_submit.results }}"

    - name: Pause for a bit.
      ansible.builtin.pause:

    - name: Getting job IDs for long-running jobs.
      include_tasks: demo_status.yml
      loop: "{{ job_submit.results }}"

    - name: Querying jobs.
      ibm.ibm_zos_core.zos_job_query:
        job_id: "{{ item.value.job_id }}"
      loop: "{{ job_outputs|dict2items }}"

demo_status.yml

---
- name: Get output for current job.
  async_status:
    jid: "{{ item.ansible_job_id }}"
  register: current_job
  until: current_job.finished
  retries: 10

- name: Registering current job output.
  set_fact:
    job_outputs: "{{ job_outputs | combine( { current_job.job_id: current_job } ) }}"
@fernandofloresg fernandofloresg added the Enhancement Enhancement to existing collection content label Jan 17, 2025
@fernandofloresg fernandofloresg added the Post plan issue Added to a quarter after planning wsa completed, thus unaplanned. label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Enhancement to existing collection content Post plan issue Added to a quarter after planning wsa completed, thus unaplanned.
Projects
Status: 📗In plan
Development

No branches or pull requests

2 participants