Coding the variables in the Jinja2 templates

Some building blocks such as template, job_submit, ims_mfsutl, and ims_olcutl use Jinja2 templates. The variables that are used in the Jinja2 templates must be defined in the environment variables file or as extra_vars variables.

The following code shows the example of a Jinja2 template that calls both types of variables in Ansible:
//{{template_values['jobcard']}}
//STEP0001 EXEC PGM=IEBGENER
//SYSIN    DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT1   DD *
"{{ msg if msg is defined else 'HELLO WORLD' }}"
/*
//SYSUT2   DD SYSOUT=*
//
Note: You can enter {{template_values.jobcard}} instead of {{template_values['jobcard']}}.
The following code shows the example of a Jinja2 template that calls both types of variables in Python. Enter the environment prefix to call an environment variable.
//{{environment.template_values['jobcard']}}
//STEP0001 EXEC PGM=IEBGENER
//SYSIN    DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT1   DD *
"{{ msg if msg is defined else 'HELLO WORLD' }}"
/*
//SYSUT2   DD SYSOUT=*
//
Note: You can enter {{template_values.jobcard}} instead of {{template_values['jobcard']}}.
As you can see, this Jinja2 template calls the following variables:
  • jobcard, which must be declared in the environment variables file. For example, you can declare it in the following way:
    template_values:
      jobcard: "TEMJCL JOB 'WD-JCL-TEMPLATE',MSGLEVEL=(1,1),MSGCLASS=R,NOTIFY=&SYSUID"
    
  • msg, which is an extra_vars variable to be declared as an argument in The Ansible deployment command or The Python deployment command.
    For example, you can enter the following argument in the Ansible deployment command:
    ansible-playbook deploy.yml -e msg=GOODBYE
    For example, you can enter the following argument in the Wazi Deploy Python deployment command:
    wazideploy-deploy\
       -e msg=GOODBYE
Note: The following elements can also be used in the Jinja2 templates: deployment_plan, activity, action, and step of the deployment plan.