forked from IBM/z_ansible_collections_samples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zos_script.yml
83 lines (73 loc) · 2.9 KB
/
zos_script.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
###############################################################################
# © Copyright IBM Corporation 2023, 2024
###############################################################################
###############################################################################
# This playbook demonstrates how to use zos_script to run local and remote
# scripts in z/OS using Red Hat Ansible Certified Content for IBM Z.
#
# Usage:
# ansible-playbook -i <inventory> <playbook>
#
# Example:
# ansible-playbook -i inventories zos_script.yml
#
# Requirements:
# IBM z/OS core collection 1.8.0 or later.
#
# Configure:
# python_script_dir - Directory where the Python script will be run (mostly
# to test the chdir option in zos_script).
# show_current_time - Whether to print the current time on the managed node
# when running the CATALOG script.
# show_header - Whether to print a header when running the CATALOG script.
# rexx_header - Content of the header that will be used in the CATALOG
# script.
###############################################################################
- name: Sample zos_script playbook.
hosts: zos_host
collections:
- "ibm.ibm_zos_core"
gather_facts: false
environment: '{{ environment_vars }}'
vars:
python_script_dir: "/u/user_name"
show_current_time: true
show_header: true
rexx_header: "#--- Current catalog information ---#"
tasks:
# For this task, we can give arguments directly to the script by writing
# them after the command that we're interested in running on the managed
# node. Make sure to replace the values of the arguments.
- name: Run REXX script to get a job's information.
ibm.ibm_zos_core.zos_script:
cmd: "{{ playbook_dir }}/files/JOB_INFO JOBID=ID OWNER=OWNER JOBNAME=NAME"
remote_src: false
register: job_output
- name: See Job information.
ansible.builtin.debug:
msg: "{{ job_output }}"
# For this task, we're trying out 'executable' and 'chdir' to have more
# control over the way a script is run.
- name: Run Python script in a given directory.
ibm.ibm_zos_core.zos_script:
cmd: "{{ playbook_dir }}/files/list_dir.py"
chdir: "{{ python_script_dir }}"
executable: "{{ ansible_python_interpreter }}"
remote_src: false
register: python_output
- name: See Python output.
ansible.builtin.debug:
msg: "{{ python_output }}"
# For the last task, we're trying out a template of a REXX script. See
# the variables defined above.
- name: Run template of a REXX script.
ibm.ibm_zos_core.zos_script:
cmd: "{{ playbook_dir }}/files/CATALOG"
remote_src: false
use_template: true
template_parameters:
keep_trailing_newline: true
register: template_output
- name: See script's output.
ansible.builtin.debug:
msg: "{{ template_output }}"