template
With this building block, you can write templates to create shell scripts, JCLs, or any type of file. This building block is not related to artifacts.
You create your own templates in the folder of your choice. You must write them in Jinja2. For more information, see the Jinja2 documentation.
Then, you run the template
building block to transform the Jinja2 files into
the target files.
actions:
- name: CREATE FILES FROM A TEMPLATE
short_name: CREATE_FROM_TEMPLATE
steps:
- name: TEST STEP FOR TEMPLATE
short_name: TEST_TEMPLATE
properties:
- key: template
value: template
- key: var_template_name
value: templ01jcl
In this example, the value of the var_template_name
property is
templ01jcl
, but it can be any other string.
To run correctly, this building block requires environment variables. Indicate them in a .yml file. Indicate The generic environment variables for the Ansible and Python building blocks and adapt their values to your target z/OS environment. Indicate also the variables that are specific to this building block.
The Ansible variables
var_template_name
property:- The src variable, which indicates a full or
relative path to the Jinja2 source file, named a Jinja2 template, on the Ansible controller. This variable is required.
To know how to define the variables in your Jinja2 template, see Coding the variables in the Jinja2 templates.
- The dest variable, which indicates a full or relative path to the target file to be created on the Ansible controller. This variable is required.
- The mode variable, which indicates the permissions on the
target file. For example, it can be
0755
. This variable is optional. - The owner variable, which indicates the default name of the user that the target file belongs to. This variable is optional.
- The group variable, which indicates the default name of the group that the target file belongs to. This variable is optional.
templ01jcl
as the value of the var_template_name
property. So, you
can enter the following lines in the variables file:templ01jcl:
src: "source_templates/test01-jcl.j2"
dest: "source_templates/test01.jcl
mode: 0777
owner: testuser
group: test_team
var_template_name
property in the
deployment method, then the template_name_default group variable is used. This
variable must be declared in the environment variables file.template_name_default:
src: "spec_templates/ex01-sh.j2"
dest: "spec_templates/ex01.sh"
owner: user01
group: wd_devteam
mode: 0755
The Python variables
--envFile
argument of The Python deployment command. var_template_name
property uses the following variables:- The src variable, which indicates a full or
relative path to the Jinja2 source file, named a Jinja2 template, on the local file system. This variable is required.
To know how to define the variables in your Jinja2 template, see Coding the variables in the Jinja2 templates.
- The dest variable, which indicates a full or relative path to the target file to be created on the Ansible controller. This variable is required.
- The mode variable, which indicates the permissions on the
target file. For example, it can be
0755
. This variable is optional.
templ01jcl
as the value of the var_template_name
property. So, you
can enter the following lines in the variables file:templ01jcl:
src: "source_templates/test01-jcl.j2"
dest: "wd_test/inventory_hostname_test01.jcl"
mode: 0777
var_template_name
property in the
deployment method, then the template_name_default group variable is used. This
variable must be declared in the environment variables file.template_name_default:
src: "HELLO-jcl.j2"
dest: "/tmp/my_jcl/HELLO.jcl"
mode: 0755
Return values
The result of each building block task is displayed in the evidence file, in The results level that is embedded in step_result.