AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible on z/OS 3.1 Automation Complete Guide

By Luca Berton · Published 2024-01-01 · Category: installation

Automate IBM z/OS 3.1 with Ansible: ibm_zos_core collection, JCL submission, datasets, USS, z/OSMF workflows, RACF, MVS commands.

IBM z/OS 3.1 (released September 2023) is the modern mainframe OS for IBM z16/z17 with AI on Z, container support via zCX, and OpenSSH/Python integrations through z/OS OMVS. Ansible automates z/OS through the ibm.ibm_zos_core collection (and friends ibm.ibm_zos_cics, ibm.ibm_zos_ims, ibm.ibm_zosmf), driving JCL submission, dataset management, USS files, and z/OSMF workflows. This is the master Ansible guide for z/OS 3.1.

z/OS 3.1 release facts

| Item | Value | |---|---| | Released | 2023-09-29 | | Hardware | IBM z15 / z16 / z17 | | Key features | AI on Z, zCX containers, modern OpenSSH/Python in OMVS | | Ansible APIs | Z Open Automation Utilities (ZOAU), z/OSMF REST |

See also: Ansible AWS: Complete Guide to Cloud Automation (2026)

Ansible-core compatibility

Use ansible-core 2.18 LTS. The collection requires: • IBM Open Enterprise SDK for Python in OMVS • Z Open Automation Utilities (ZOAU) ≥ 1.3 • SSH access to USS

[zos:vars]
ansible_python_interpreter=/usr/lpp/IBM/cyp/v3r10/pyz/bin/python3
ansible_zoau_path=/usr/lpp/IBM/zoautil

Collection:

collections:
  - name: ibm.ibm_zos_core
    version: ">=1.10.0"
  - name: ibm.ibm_zosmf
    version: ">=1.5.0"

Inventory

[zos]
zos01 ansible_host=mvs01.lab.example.com

[zos:vars] ansible_user=ANSUSR ansible_password='{{ vault_zos_password }}' ansible_connection=ssh

See also: Ansible Become: Privilege Escalation with sudo, su & runas (Complete Guide)

Submit JCL

- name: Submit a JCL job
  hosts: zos
  gather_facts: false
  tasks:
    - name: Submit JCL
      ibm.ibm_zos_core.zos_job_submit:
        src: /u/ansusr/jcl/HELLOJOB.jcl
        location: USS
        wait_time_s: 120
      register: job

- name: Show job status ansible.builtin.debug: msg: "Job {{ job.jobs[0].job_name }} RC={{ job.jobs[0].ret_code.code }}"

Manage a sequential dataset

- name: Create a PS dataset
  hosts: zos
  gather_facts: false
  tasks:
    - name: Allocate
      ibm.ibm_zos_core.zos_data_set:
        name: ANSUSR.APP.CONFIG
        type: SEQ
        space_primary: 5
        space_secondary: 1
        space_type: TRK
        record_format: FB
        record_length: 80
        state: present

- name: Push content from USS ibm.ibm_zos_core.zos_copy: src: /u/ansusr/config/app.cfg dest: ANSUSR.APP.CONFIG remote_src: true

See also: Ansible check_mode: Dry Run & Test Playbooks Without Making Changes

z/OSMF workflow

- name: Run z/OSMF workflow
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Create + start workflow
      ibm.ibm_zosmf.zmf_workflow:
        zmf_host: zosmf.lab.example.com
        zmf_port: 443
        zmf_user: ANSUSR
        zmf_password: "{{ vault_zos_password }}"
        workflow_name: ApplyAPAR
        workflow_file: /usr/lpp/zosmf/samples/sampleworkflow.xml
        system_name: SY1
        owner: ANSUSR
        state: started

RACF user

- name: Add user via TSO command
  hosts: zos
  gather_facts: false
  tasks:
    - name: ADDUSER through zos_tso_command
      ibm.ibm_zos_core.zos_tso_command:
        commands:
          - "ADDUSER APPUSR1 PASSWORD(P@ssw0rd1) DFLTGRP(USERS) NAME('APP USER')"
          - "PERMIT ANSUSR.APP.* ID(APPUSR1) ACCESS(READ)"
          - "SETROPTS REFRESH RACLIST(DATASET)"

Best practices

• Use z/OSMF workflows for installer-style operations and JCL chains; use ZOAU/Ansible for fleet management. • Store JCL templates as Jinja2 in the Git repo, render and push to USS before submission. • Pin ZOAU and Python locations explicitly per LPAR; don't rely on PATH. • Use a RACF service ID with surrogate authority instead of the operator ID.

Conclusion

z/OS 3.1 + ibm.ibm_zos_core and ibm.ibm_zosmf make the mainframe a first-class Ansible target. Combine JCL submission, dataset modules, USS file ops, and z/OSMF workflows to bring the z platform into modern enterprise automation pipelines.

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home