Skip to content

Commit

Permalink
Change read me and case
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMarcel99 committed Aug 27, 2024
1 parent c80ff5d commit 94dcaf9
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 44 deletions.
4 changes: 2 additions & 2 deletions zos_concepts/gdg_datasets/copy_edit_fetch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This playbook uses:
- ibm.ibm_zos_core
- modules:
- zos_copy
- zos_dataset
- zos_data_set
- zos_fetch
- zos_blockinfile
- zos_lineinfile
Expand Down Expand Up @@ -41,7 +41,7 @@ names, authority, and the artifacts that will be created and cleaned up.

This playbook requires:
- [IBM® z/OS® core collection 1.11.0 or later](https://galaxy.ansible.com/ibm/ibm_zos_core)
- [Ansible® 2.5 or later](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)
- [Ansible® 2.15 or later](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)

## Configuration
- Configure the included [inventory.yml](inventories/inventory.yml) with the
Expand Down
113 changes: 71 additions & 42 deletions zos_concepts/gdg_datasets/copy_edit_fetch/copy_edit_fetch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
###############################################################################

###############################################################################
# This sample playbook demonstrates how to add text content to a GDS copy to
# another generation, edit the copy and fetch the content.
# 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>
Expand All @@ -30,96 +31,124 @@

tasks:
# ##########################################################################
# Generate a temporary data set name and get last two minutes of logs.
# Generate a temporary data set names, date time, system name and get last
# four minutes of the operator console log.
# ##########################################################################
- name: Create temp data set name
command: "mvstmp {{ ansible_user | upper }}"
register: tmp_ds
register: tmp_ds1

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

- name: Get date time
shell: "date +%Y-%m-%d%H:%M:%S"
register: date_time

- name: Get system name
command: "zinfo -j -t sys"
register: sys_info

- name: Check content of last four minutes of console log
command: "pcon -t 4"
register: tmp_text
register: log_output

- set_fact:
tmp_data_set: "{{ tmp_ds.stdout }}"
tmp_data_set1: "{{ tmp_ds1.stdout }}"
tmp_data_set2: "{{ tmp_ds2.stdout }}"
date: "{{ date_time.stdout[0:10] }}"
time: "{{ date_time.stdout[10:] }}"
sys_info: "{{ sys_info.stdout | from_json}}"
log_output: "{{ log_output.stdout }}"

- set_fact:
tmp_text: "{{ tmp_text.stdout }}"
sys_name: "{{ sys_info.data.sys_info.sys_name }}"
# ##########################################################################
# Modules: zos_dataset, zos_blockinfile, zos_copy,
# zos_lineinfile, zos_fetch
# Modules: zos_data_set, zos_blockinfile, zos_copy,
# zos_lineinfile, zos_fetch.
# ##########################################################################
# +-------------------------------------------------------------------------
# | - Using zos_data_set, create the generation data group with name
# | {{ tmp_data_set }}
# | - Using zos_data_set, create first generation of the GDG.
# | - Using zos_data_set, create second generation of the GDG.
# | - Using zos_blockinfile, add the logs to the latest generation of GDG.
# | - Using zos_copy, copy the content from the latest generation to a previous one.
# | - Using zos_lineinfile, add a comment to a previous generation of
# | the GDG using relative notation notation {{ tmp_data_set }}(-1).
# | - Using zos_fetch, to fetch the previous generation of the GDG.
# | - Using zos_data_set, create the generation data groups with names
# | {{ tmp_data_set1 }} and {{ tmp_data_set2 }}
# | - Using zos_data_set, create a generation of the GDG from {{ tmp_data_set1 }}.
# | - Using zos_data_set, create a generation of the GDG from {{ tmp_data_set2 }}.
# | - Using zos_blockinfile, add the logs to the latest generation of GDG {{ tmp_data_set1 }}.
# | - Using zos_copy, copy the content from the latest generation of {{ tmp_data_set1 }}
# | - latest generation of {{ tmp_data_set2 }}.
# | - Using zos_lineinfile, add a comment to a latest generation of {{ tmp_data_set2 }}
# | using relative notation notation {{ tmp_data_set2 }}(-1).
# | - Using zos_fetch, to fetch the latest generation of the GDG {{ tmp_data_set2 }}.
# +-------------------------------------------------------------------------
- name: "Create the GDG {{tmp_data_set}} with limit of 2"
- name: "Create the Generation Data Group(GDG) {{tmp_data_set1}} with a limit of 2 generations"
zos_data_set:
name: "{{ tmp_data_set1 }}"
type: gdg
limit: 2
register: result_create_gdg

- name: "Create the Generation Data Group(GDG) {{tmp_data_set2}} with a limit of 2 generations for backup {{tmp_data_set1}}"
zos_data_set:
name: "{{ tmp_data_set }}"
name: "{{ tmp_data_set2 }}"
type: gdg
limit: 2
register: result_create_gdg

- name: "Response the creation of the GDG {{ tmp_data_set }} with limit of 2"
- name: "Response of the GDG creation {{ tmp_data_set2 }} with a limit of 2 generations"
debug:
msg:
- "{{ result_create_gdg }}"

- name: "Create the GDS with record length of 200"
- name: "Create the GDS for {{ tmp_data_set1 }} of sequential type and record length of 200"
zos_data_set:
name: "{{ tmp_data_set }}(+1)"
name: "{{ tmp_data_set1 }}(+1)"
type: seq
record_length: 200
state: "present"

- name: "Create the GDS with record length of 200"
- name: "Create the GDS for {{ tmp_data_set2 }} of sequential type and record length of 200"
zos_data_set:
name: "{{ tmp_data_set }}(+1)"
name: "{{ tmp_data_set2 }}(+1)"
type: seq
record_length: 200
state: "present"
register: result_create_gds_relative
register: result_create_gds

- name: "Response of the creation of the GDS {{ tmp_data_set }}(+1)"
- name: "Response of the GDS {{ tmp_data_set2 }}(+1) creation"
debug:
msg:
- "{{ result_create_gds_relative }}"
- "{{ result_create_gds }}"

- name: "Add the last 4 minutes of console log of to {{ tmp_data_set }}(0)"
- name: "Write into {{ tmp_data_set1 }}(0) the last 4 minutes of the operator console log"
zos_blockinfile:
src: "{{ tmp_data_set }}(0)"
src: "{{ tmp_data_set1 }}(0)"
marker: "//* {mark} *//"
marker_begin: " Log of date {{ date }} "
marker_end: " End of log time {{ time }} "
insertbefore: BOF
state: present
block: "{{ tmp_text }}"
block: "{{ log_output }}"

- name: "Copy from the last creation to the first of the GDS {{ tmp_data_set }}"
- name: "Copy from the current generation of {{ tmp_data_set1 }} to the last Generation of {{ tmp_data_set2 }}"
zos_copy:
src: "{{ tmp_data_set }}(0)"
dest: "{{ tmp_data_set }}(-1)"
src: "{{ tmp_data_set1 }}(0)"
dest: "{{ tmp_data_set2 }}(0)"
remote_src: true

- name: "Edit first creation of GDG to add a comment"
- name: "Edit last generation {{ tmp_data_set2 }} to add a comment"
zos_lineinfile:
src: "{{ tmp_data_set }}(-1)"
src: "{{ tmp_data_set2 }}(0)"
insertbefore: BOF
state: present
line: "#### Last 4 minutes of console log"
line: "#### Console log from system {{ sys_name }} ####"

- name: "Fetch {{ tmp_data_set }}(-1) to the local machine"
- name: "Fetch {{ tmp_data_set2 }}(0) to the local controller"
zos_fetch:
src: "{{ tmp_data_set }}(-1)"
src: "{{ tmp_data_set2 }}(0)"
dest: "{{ playbook_dir }}/"
register: result_of_fetch
register: fetch_result

- name: "Result of Fetch {{ tmp_data_set }}(0) to the local machine"
- name: "Result of Fetch {{ tmp_data_set2 }}(0) to the local machine"
debug:
msg:
- "{{ result_of_fetch }}"
- "{{ fetch_result }}"

0 comments on commit 94dcaf9

Please sign in to comment.