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

updated data set basics, submit query retrieve and zos_script #280

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
361 changes: 181 additions & 180 deletions zos_concepts/data_sets/data_set_basics/data_set_basics.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,180 +1,181 @@
###############################################################################
# © Copyright IBM Corporation 2020, 2024
###############################################################################
# This sample playbook demonstrates basic data set operations using modules
# included in the Red Hat Ansible Certified Content for IBM Z core collection.
#
# Usage:
# ansible-playbook -i <inventory> <playbook>
#
# Example:
# ansible-playbook -i inventories data_set_basics.yml
# ansible-playbook -i inventories data_set_basics.yml -v
#
# Additional facts for this playbook can be configured to override the defaults
# by reviewing the "Fact setting" section of this playbook, for example,
# `data_set_name` and `system_name`.
#
# Requirements:
# IBM z/OS core collection 1.2.0 or later
#
# Configure:
# tgt_tmp_dir - this is the USS directory on the target which will be written
# to for this example.
#
# Optional:
# data_set_name - this is the data set name that will be created during
# execution of this sample.
# pds_name - this is the pds name that will be used during execution of this
# sample.
# system_name - this is the system name that will be used during this example,
# determined by executing `uname -n` on the target.
###############################################################################

---

- hosts: zos_host
collections:
- ibm.ibm_zos_core
gather_facts: false
vars:
tgt_tmp_dir: "/tmp"
environment: "{{ environment_vars }}"

tasks:
# ##########################################################################
# Generate and set temporary names for data sets
# ##########################################################################
- name: Create temp sequential data set name
command: "mvstmp {{ ansible_user | upper }}"
register: tmp_ds_seq

- name: Create temp PDS name
command: "mvstmp {{ ansible_user | upper }}"
register: tmp_ds_pds

- name: Set names for sequential data set and pds for use by this sample
set_fact:
data_set_name: "{{ tmp_ds_seq.stdout }}"
pds_name: "{{ tmp_ds_pds.stdout }}"

- name: Fact `data_set_name` and `pds_name` set with values
debug:
msg:
- "sequential data set name - {{ data_set_name }}"
- "pds name - {{ pds_name }}"

############################################################################
# Modules zos_copy, zos_data_set, zos_fetch
############################################################################
# +-------------------------------------------------------------------------
# | 1. Create a sequential data set
# | 2. Create a USS file and populate it with some data
# | 3. Copy the USS file to the sequential data set
# | 4. Create a PDS and a member within the PDS
# | 5. Copy the sequential data set to the PDS member
# | 6. Create a new PDS, replacing the existing one
# | 7. Delete all data sets that were created during playbook execution
# +-------------------------------------------------------------------------

- name: Create a sequential data set
zos_data_set:
name: "{{ data_set_name }}"
type: seq
state: present
replace: true
format: fb
record_length: 100
space_primary: 5
space_type: m
register: result

- name: Response for data set creation
debug:
msg: "{{ result }}"

- name: Remove old {{ tgt_tmp_dir }}/HELLO if it exists, for idempotency
file:
path: "{{ tgt_tmp_dir }}/HELLO"
state: absent
register: result

- name: Response for USS file deletion
debug:
msg: "{{ result }}"

- name: Copy HELLO.jcl from project to USS file
zos_copy:
src: "{{ playbook_dir }}/files/HELLO.jcl"
dest: "{{ tgt_tmp_dir }}/HELLO"
register: result

- name: Response for populating USS file {{ tgt_tmp_dir }}/HELLO
on target {{ inventory_hostname }}
debug:
msg: "{{ result }}"

- name: Copy the USS file to the sequential data set
zos_copy:
src: "{{ tgt_tmp_dir }}/HELLO"
dest: "{{ data_set_name }}"
remote_src: true
register: result

- name: Response for copying USS file to data set
debug:
msg: "{{ result }}"

- name: Create a PDS
zos_data_set:
name: "{{ pds_name }}"
type: pds
space_primary: 5
space_type: m
format: fba
record_length: 100
register: result

- name: Response for creating the PDS
debug:
msg: "{{ result }}"

- name: Remove the target PDS member if it exists, for idempotency.
zos_data_set:
name: "{{ pds_name }}(HELLO)"
type: member
state: absent
register: result

- name: Response for removing the PDS member
debug:
msg: "{{ result }}"

- name: Copy the sequential data set to PDS member
zos_copy:
src: "{{ data_set_name }}"
dest: "{{ pds_name }}(HELLO)"
remote_src: true
register: result

- name: Response for copying {{ data_set_name }} to {{ pds_name }}(HELLO)
debug:
msg: "{{ result }}"

- name: Delete the data sets
zos_data_set:
batch:
- name: "{{ data_set_name }}"
state: absent
- name: "{{ pds_name }}"
state: absent
register: result

- name: Response for deleting the data sets
debug:
msg: "{{ result }}"

- name: Clean up {{ tgt_tmp_dir }}
file:
path: "{{ tgt_tmp_dir }}/HELLO"
state: absent
###############################################################################
# © Copyright IBM Corporation 2020, 2021
###############################################################################
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# © Copyright IBM Corporation 2020, 2021
# © Copyright IBM Corporation 2020, 2024

# This sample playbook demonstrates basic data set operations using modules
# included in the Red Hat Ansible Certified Content for IBM Z core collection.
#
# Usage:
# ansible-playbook -i <inventory> <playbook>
#
# Example:
# ansible-playbook -i inventories data_set_basics.yml
# ansible-playbook -i inventories data_set_basics.yml -v
#
# Additional facts for this playbook can be configured to override the defaults
# by reviewing the "Fact setting" section of this playbook, for example,
# `data_set_name` and `system_name`.
#
# Requirements:
# IBM z/OS core collection 1.2.0 or later
#
# Configure:
# tgt_tmp_dir - this is the USS directory on the target which will be written
# to for this example.
#
# Optional:
# data_set_name - this is the data set name that will be created during
# execution of this sample.
# pds_name - this is the pds name that will be used during execution of this
# sample.
# system_name - this is the system name that will be used during this example,
# determined by executing `uname -n` on the target.
###############################################################################

---
- hosts: all
collections:
- ibm.ibm_zos_core
gather_facts: no
vars:
tgt_tmp_dir: "/tmp"
environment: "{{ environment_vars }}"

tasks:
# ##########################################################################
# Generate and set temporary names for data sets
# ##########################################################################
- name: Create temp sequential data set name
command: "mvstmp {{ ansible_user | upper }}"
register: tmp_ds_seq

- name: Create temp sequential data set name
command: "mvstmp {{ ansible_user | upper }}"
register: tmp_ds_pds

- name: Set names for sequential data set and pds for use by this sample
set_fact:
data_set_name: "{{ tmp_ds_seq.stdout }}"
pds_name: "{{ tmp_ds_pds.stdout }}"

- name: Fact `data_set_name` and `pds_name` set with values
debug:
msg:
- "sequential data set name - {{ data_set_name }}"
- "pds name - {{ pds_name }}"

############################################################################
# Modules zos_data_set, zos_fetch
############################################################################
# +-------------------------------------------------------------------------
# | 1. Create a sequential data set
# | 2. Create a USS file and populate it with some data
# | 3. Copy the USS file to the sequential data set
# | 4. Create a PDS and a member within the PDS
# | 5. Copy the sequential data set to the PDS member
# | 6. Create a new PDS, replacing the existing one
# | 7. Delete all data sets that were created during playbook execution
# +-------------------------------------------------------------------------

- name: Create a sequential data set
zos_data_set:
name: "{{ data_set_name }}"
type: seq
state: present
replace: true
format: fb
record_length: 100
space_primary: 5
space_type: m
register: result

- name: Response for data set creation
debug:
msg: "{{ result }}"

- name: Create a USS file
file:
path: "{{ tgt_tmp_dir }}/HELLO"
state: touch
register: result

- name: Response for USS file creation
debug:
msg: "{{ result }}"

- name: zos_copy
zos_copy:
src: "{{ playbook_dir }}/files/HELLO.jcl"
dest: "{{ tgt_tmp_dir }}/HELLO"
# remote_src: yes
force: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this

register: result

- name: Response for populating USS file {{ tgt_tmp_dir }}/HELLO
on target {{ inventory_hostname }}
debug:
msg: "{{ result }}"

- name: Copy the USS file to the sequential data set
zos_copy:
src: "{{ tgt_tmp_dir }}/HELLO"
dest: "{{ data_set_name }}"
remote_src: yes
register: result

- name: Response for copying USS file to data set
debug:
msg: "{{ result }}"

- name: Create a PDS
zos_data_set:
name: "{{ pds_name }}"
type: pds
space_primary: 5
space_type: m
format: fba
record_length: 100
register: result

- name: Response for creating the PDS
debug:
msg: "{{ result }}"

- name: Create a PDS member
zos_data_set:
name: "{{ pds_name }}(HELLO)"
type: member
register: result

- name: Response for creating the PDS member
debug:
msg: "{{ result }}"

- name: Copy the sequential data set to PDS member
zos_copy:
src: "{{ data_set_name }}"
dest: "{{ pds_name }}(HELLO)"
remote_src: yes
force: true
register: result

- name: Response for copying {{ data_set_name }} to {{ pds_name }}(HELLO)
debug:
msg: "{{ result }}"

- name: Delete the data sets
zos_data_set:
batch:
- name: "{{ data_set_name }}"
state: absent
- name: "{{ pds_name }}"
state: absent
register: result

- name: Response for deleting the data sets
debug:
msg: "{{ result }}"

- name: Clean up {{ tgt_tmp_dir }}
file:
path: "{{ tgt_tmp_dir }}/HELLO"
state: absent
Loading
Loading