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

[Module][Playbook][1720]Playbook_zfs_resize #295

Open
wants to merge 5 commits 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ often repeated and in need of automation.
- [Dump, Archive, Fetch, Copy and Unarchive Data Sets](zos_concepts/data_transfer/archive_copy_unarchive_restore)
- [Transfer, Dump and Unpack Data Sets](zos_concepts/data_transfer/dump_pack_ftp_unpack_restore)
- [Grow ZFS aggregates](zos_concepts/zfsadm/zfs_grow_aggr)
- [Grow ZFS fetch full trace back](zos_concepts/zfsadm/grow_zfs_fetch_full_trace_back)
- [Copy templates to z/OS](zos_concepts/templates/copy_template)
- [Use templated job cards and JCL to submit jobs](zos_concepts/templates/submit_job_template)
- [Use templates for compiling and linking libraries](zos_concepts/templates/loadlib)
Expand Down Expand Up @@ -113,6 +114,7 @@ often repeated and in need of automation.
- [Security validation](zos_management/zosmf_security_configuration_assistant)
- [Security audit](zos_management/zosmf_security_configuration_assistant)
- [Security provision](zos_management/zosmf_security_configuration_assistant)
- [Shrink on different size and see full verbose](zos_concepts/zfsadm/shrink_zfs_different_size_and_verbose)


## Blogs
Expand Down
66 changes: 66 additions & 0 deletions zos_concepts/zfsadm/grow_zfs_fetch_full_trace_back/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Create, grow ZFS aggregate with trace back and fetch the trace member.
This playbook demonstrates how to grow a ZFS aggregate on z/OS using Red Hat
Ansible Certified Content for IBM Z.

This playbook uses:
- collection:
- ibm.ibm_zos_core
- modules:
- zos_data_set
- zos_mount
- zos_zfs_resize
- zos_fetch

It is a good practice to review the playbook contents before executing
them. It will help you understand the requirements in terms of space, location,
names, authority, and the artifacts that will be created and cleaned up.

## Playbook Requirements
This playbook requires:

- [IBM® z/OS® core collection 1.13.0 or later](https://galaxy.ansible.com/ibm/ibm_zos_core)
- [Ansible® 2.16 or later](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)

## Configuration
- Configure the included [inventory.yml](inventories/inventory.yml) with the
information from the managed z/OS host.
- Review [inventory documentation](../../../docs/share/zos_core/configure_inventory.md)
- Configure the included **host_vars** [zos_host.yml](inventories/host_vars/zos_host.yml)
with the information from your z/OS system.
- Review [host_vars documentation](../../../docs/share/zos_core/configure_host_vars.md)
and any additional noted variables in the configuration.

## Run the playbook
This project has included a `site.yml` playbook that serves as the primary playbook
that provides additional prerequisite checks then it invokes the `grow_zfs_fetch_trace_back.yml`
playbook.

If you want to run the primary playbook `site.yml` it will check that your environment
has the correct version of Ansible as well as the collection needed to execute
correctly. To run the primary playbook, use command:

```bash
ansible-playbook -i inventories site.yml
```

You can skip the prerequisite check and run the `grow_zfs_fetch_trace_back.yml` with
command:

```bash
ansible-playbook -i inventories grow_zfs_fetch_trace_back.yml
```

# Changelog
All changes are maintained chronologically by date found in the
[changelog](changelog.yml).

# Copyright
© Copyright IBM Corporation 2022

# License
Licensed under [Apache License,
Version 2.0](https://opensource.org/licenses/Apache-2.0).

# Support
Please refer to the [support section](../../../README.md#support) for more
details.
18 changes: 18 additions & 0 deletions zos_concepts/zfsadm/grow_zfs_fetch_full_trace_back/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
################################################################################
# Copyright (c) IBM Corporation 2025
################################################################################

################################################################################
# Minimum required configuration for this playbook.
# For additional `ansible.cfg` configuration options, review:
# https://docs.ansible.com/ansible/latest/reference_appendices/config.html
# https://github.com/ansible/ansible/blob/devel/examples/ansible.cfg
################################################################################

[defaults]
forks = 25
roles_path = ../../../roles:..

[ssh_connection]
pipelining = True

33 changes: 33 additions & 0 deletions zos_concepts/zfsadm/grow_zfs_fetch_full_trace_back/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
################################################################################
# Copyright (c) IBM Corporation 2025
#
# All notable changes to this project will be documented in this file. Following
# releases is a decimal based date since playbooks have no version in this
# repository.
#
# releases:
# 2025.01.06:
# date: 2025-01-06
# changes:
# added:
# - new features are added
# deprecated:
# - features being removed in the future
# fixed:
# - bug fixes
# minor:
# - changes in existing functionality
# removed:
# - features removed no longer available
# security:
# - vulnerabilities fixed
# summary:
# - summary of changes or link to Git issue, pull request
################################################################################

releases:
2025.01.06:
date: 2025-01-01
changes:
added:
- Released initial version
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
###############################################################################
# © Copyright IBM Corporation 2025
###############################################################################

###############################################################################
# This sample playbook demonstrates how to create a new Generation Data Group(GDG),
# add text content to a Generation Data Set(GDS), copy to another
# Generation Data Group(GDG), edit the copy and fetch the content.
#
# Usage:
# ansible-playbook -i <inventory> <playbook>
#
# Example:
# ansible-playbook -i inventories copy_edit_submit.yml
#
# When running this playbook, review the comments on how ths sample will
# interact with your target, ensure you have the required authority and
# permissions such as writing the the target directories or creating data sets.
#
# Requirements:
# - IBM z/OS core collection 1.13.0 or later
#
###############################################################################

---
- hosts: zos_host
collections:
- ibm.ibm_zos_core
gather_facts: false
environment: "{{ environment_vars }}"
vars:
mount_point: "/tmp/zfs_aggr"
aggr_growth_size: 2000

tasks:
# ##########################################################################
# Generate a temporary data set names
# ##########################################################################
- name: Create temp data set name
command: "mvstmp {{ ansible_user | upper }}"
register: tmp_ds1

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

- set_fact:
zfs_data_set: "{{ tmp_ds1.stdout }}"
trace_back_data_set: "{{ tmp_ds2.stdout }}"
trace_back_data_set_mem: "{{ tmp_ds2.stdout }}(MEM)"

# ##########################################################################
# Modules: zos_data_set, zos_zfs_resize, zos_fetch
# ##########################################################################
# +-------------------------------------------------------------------------
# | - Using zos_data_set, create zfs data set {{ zfs_data_set }}.
# | - Using zos_mount, mount zfs {{ zfs_data_set }} on {{ mount_point }}.
# | - Using zos_data_set, create pds data set to generate a member.
# | - Using zos_data_set, create a member to get the full trace back.
# | - Using zos_zfs_resize, resize data set {{ zfs_data_set }}.
# | - Using zos_fetch, to fetch the trace back member of the grow operation.
# +-------------------------------------------------------------------------

# ##########################################################################
# Create and Mount ZFS data set.
# ##########################################################################

- name: "Create ZFS."
zos_data_set:
name: "{{ zfs_data_set }}"
type: zfs
space_primary: 1
space_type: m
replace: true

- name: "Create mount dir on z/OS USS."
file:
path: "{{ mount_point }}"
state: directory

- name: "Mount ZFS data set."
zos_mount:
src: "{{ zfs_data_set | upper }}"
path: "{{ mount_point }}"
fs_type: zfs
state: mounted

- name: "Confirm mount point."
command: "df /{{ mount_point }}"
register: df_output

- name: "Echo df output."
debug:
msg: "{{ df_output.stdout_lines }}"

# ##########################################################################
# Create PDS data set and member for get the full trace back.
# ##########################################################################

- name: "Create data set to trace."
zos_data_set:
name: "{{ trace_back_data_set }}"
record_length: 200
type: pds

- name: "Create member of data set to trace."
zos_data_set:
name: "{{ trace_back_data_set_mem }}"
type: member

# ##########################################################################
# Fill up ZFS aggregate with random data.
# ##########################################################################

- name: "Write 1 million bytes to ZFS."
shell: head -c 1000000 /dev/urandom > {{ mount_point }}/test.txt

# ##########################################################################
# Grow ZFS aggregate.
# See the full stdout.
# Fetch the full trace back
# ##########################################################################

- name: "Grow ZFS aggregate and get trace back on data set {{ trace_back_data_set }}."

Check failure on line 124 in zos_concepts/zfsadm/grow_zfs_fetch_full_trace_back/grow_zfs_fetch_trace_back.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

syntax-check[specific]

couldn't resolve module/action 'zos_zfs_resize'. This often indicates a misspelling, missing collection, or incorrect module path.

Check failure on line 124 in zos_concepts/zfsadm/grow_zfs_fetch_full_trace_back/grow_zfs_fetch_trace_back.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

syntax-check[specific]

couldn't resolve module/action 'zos_zfs_resize'. This often indicates a misspelling, missing collection, or incorrect module path.
zos_zfs_resize:
target: "{{ zfs_data_set }}"
size: "{{ aggr_growth_size }}"
trace_destination: "{{ trace_back_data_set_mem }}"
register: grow_output

- name: Echo grow_output.
debug:
msg: "{{ grow_output }}"

- name: "Fetch {{ trace_back_data_set }} to the local controller."
zos_fetch:
src: "{{ trace_back_data_set_mem }}"
dest: "{{ playbook_dir }}/"
register: fetch_result

- name: "Result of Fetch {{ trace_back_data_set_mem }} to the local machine."
debug:
msg: "{{ fetch_result }}"

# ##########################################################################
# clean up - unmount and delete ZFS data sets
# ##########################################################################

- name: Unmount ZFS data set.
command: "/usr/sbin/unmount {{ mount_point }}"

- name: Delete ZFS data set.
zos_data_set:
name: "{{ zfs_data_set }}"
state: absent

- name: Delete trace_dataset.
zos_data_set:
name: "{{ trace_back_data_set }}"
state: absent
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
################################################################################
# Copyright (c) IBM Corporation 2025
################################################################################

################################################################################
# Enviroment variables for all z/OS managed nodes (target) that do not need
# further configuration.
################################################################################
environment_vars:
_BPXK_AUTOCVT: "ON"
ZOAU_HOME: "{{ ZOAU }}"
PYTHONPATH: "{{ ZOAU_PYTHON_LIBRARY_PATH }}"
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"

################################################################################
# Description of the properties used in this configuration:
################################################################################
# - Property BPXK_AUTOCVT must be configured to "ON"; e.g., _BPXK_AUTOCVT: "ON"
# - Property ZOAU_HOME is the Z Open Automation Utilities (ZOAU) install root path;
# e.g., ZOAU_HOME: "/usr/lpp/IBM/zoautil"
# - Property PYTHONPATH is the Z Open Automation Utilities (ZOAU) Python library path;
# e.g., PYTHONPATH: "/usr/lpp/IBM/zoautil/lib"
# - Property LIBPATH is both the path to the Python libraries on the target
# and the Z Open Automation Utilities (ZOAU) Python library path separated by semi-colons; e.g.,
# LIBPATH: "/usr/lpp/IBM/zoautil/lib/:/usr/lpp/IBM/cyp/v3r8/pyz/lib:/usr/lib:/lib:."
# - Property PATH is the ZOA utilities BIN path and Python interpreter path, e.g.,
# PATH: "/usr/lpp/IBM/zoautil/bin:/usr/lpp/IBM/cyp/v3r8/pyz/bin:/bin"
# - Property _CEE_RUNOPTS is the invocation Language Environment® runtime
# options for programs and used by Python. e.g.,
# _CEE_RUNOPTS: "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
# - Properties __TAG_REDIR_ERR, _TAG_REDIR_IN, _TAG_REDIR_OUT are txt and used
# by the shell; e.g.,
# _TAG_REDIR_ERR: "txt"
# _TAG_REDIR_IN: "txt"
# _TAG_REDIR_OUT: "txt"
# - Property LANG is the name of the default locale; value
# C specifies the POSIX locale; for example: ``LANG: "C"``.
# - Property `PYTHONSTDINENCODING` should be set to the encoding Unix System Services
# is configured as, supported encodings are ASCII or EBCDIC. This environment
# variable is used to instruct Ansible which encoding it will *pipe* content to
# Python's STDIN (standard in) when `pipelining=true` is set in `ansible.cfg` .
# This environment variable will only apply when using IBM Enterprise Python
# 3.10 or later, otherwise, it is ignored.
# For example:`PYTHONSTDINENCODING: "cp1047"`.
################################################################################
Loading
Loading