ds_create

This building block creates z/OS® data sets. It is not related to artifacts.

To trigger the execution of this building block, you can enter the following code in the deployment method from which the deployment plan is generated. See How to trigger the execution of a building block. The following code is an example.
actions:
    - name: CREATE ZOS DATA SETS
      short_name: CREATE_DATA_SETS
      steps:
      - name: TEST STEP FOR DS_CREATE
        short_name: TEST_DS_CREATE
        properties:
        - key: template
          value: ds_create
        - key: var_ds_create
          value: new_data_sets

You can enter the var_ds_create property to indicate the name of the variable that contains the list and characteristics of the data sets to be created. In the example, the value of this property is new_data_sets, but it can be any other string.

The ds_create building block for Ansible

The ds_create building block for Ansible® creates all the z/OS data set types (KSDS, ESDS, RRDS, LDS, SEQ, PDS, PDSE, LIBRARY, BASIC, LARGE, MEMBER, HFS, ZFS), except the GDG and ALIAS types.

If you specify the var_ds_create property in a step of the deployment method, you must assign the value to its corresponding variable in an Ansible environment variables file. In the following example, the new_data_sets variable that was declared in the deployment method contains two types of data sets to be created (IBMUSER.DATASET.SEQ01 and IBMUSER.DATASET.PDS01).
new_data_sets:
- name: IBMUSER.DATASET.SEQ01
  spec:
    type: SEQ
    space_primary: 5
    space_secondary: 2
    space_type: TRK
    record_format: FB
    record_length: 20
- name: IBMUSER.DATASET.PDS01
  spec:
    type: PDS
    space_primary: 4
    space_secondary: 2
    space_type: TRK
    record_format: FB
    record_length: 80
As you can see in this sample code, you must declare the following variables:
  • The name variable that contains the name of the new data set.
  • The spec variable that contains the following embedded variables:
    • The type variable that represents the data set type, such as SEQ, PDS, or PDSE.
    • The data set parameters, such as space_primary or record_length. See the zos_data_set parameters in the Ansible documentation of the IBM® z/OS collections.
If you do not indicate the variables in the step properties of the deployment method, then the ds_create building block uses the default ds_create_lsds_default variable and its associated variables from an Ansible environment variables file.
hlq: 'NAZARE.WDEPLOY.ANSIBLE'

common_pds_load_spec:
  type: LIBRARY
  space_primary: 10
  space_secondary: 20
  space_type: CYL
  record_format: U
  record_length: 0

ds_create_lsds_default:
- name: '{{ hlq }}.LIB'
  spec: '{{common_pds_load_spec}}'

This default variable uses common variables (common_pds_load_spec in the sample code) that define the characteristics of the z/OS data sets. These variables prevent the repetition of the same values in the continuation of the variables file. Adapt the values of their embedded variables to your needs.

This default variable has the following two embedded variables:
  • A name variable for the name of the data set to be created. In this example, the prefix of the data set name is constituted of the high-level qualifier (hlq).
  • A spec variable to use the values of the common variables for the data set characteristics.

The ds_create building block for Python

The ds_create building block for Python creates the following types of z/OS data sets: SEQ, PDS, PDSE, LIBRARY, BASIC, and LARGE. It cannot be used to create MEMBER data set type or VSAM files.

If you specify the var_ds_create property in a step of the deployment method, you must assign the value to its corresponding variable in a Python environment variables file. In the following example, the new_data_sets variable that was declared in the deployment method contains two types of data sets to be created (IBMUSER.DATASET.SEQ01 and IBMUSER.DATASET.PDS01).
new_data_sets:
- name: IBMUSER.DATASET.SEQ01
  spec:
    type: SEQ
    primary_space: 8TRK
    secondary_space: 4TRK
    record_format: FB
    record_length: 25
- name: IBMUSER.DATASET.PDS01
  spec:
    type: PDS
    primary_space: 6TRK
    secondary_space: 3TRK
    record_format: FB
    record_length: 80
As you can see in this sample code, you must declare the following variables:
  • The name variable that contains the name of the new data set.
  • The spec variable that contains the following embedded variables:
    • The type variable that represents the data set type, such as SEQ, PDS, or PDSE.
    • The data set parameters, such as primary_space or record_length.

You can also indicate an optional replace parameter to handle the creation of the data set. If this parameter is set to True and if the data set already exists, then the existing data set will be deleted and replaced with the data set that will be created by the ds_create building block. If this parameter is set to False, the data set will not be created.

If you do not indicate the variables in the step properties of the deployment method, then the ds_create building block uses the default ds_create_lsds_default variable and its associated variables from a Python environment variables file.
hlq: 'NAZARE.WDEPLOY.PYTHON'

common_pds_load_spec:
  type: LIBRARY
  primary_space: 5TRK
  secondary_space: 2TRK
  record_format: U
  record_length: 0 

ds_create_lsds_default:
- name: '{{ hlq  }}.LIB01'
  spec: '{{common_pds_load_spec}}'
- name: '{{ hlq  }}.SEQ01'
  spec: '{{seq_spec}}' 
- name: '{{ hlq  }}.PDS01'
  spec: '{{common_pds_load_spec}}'

This default variable uses common variables (common_pds_load_spec in the sample code) that define the characteristics of the z/OS data sets. These variables prevent the repetition of the same values in the continuation of the variables file. Adapt the values of their embedded variables to your needs.

This default variable has the following two embedded variables:
  • A name variable for the name of the data set to be created. In this example, the prefix of the data set name is constituted of the high-level qualifier (hlq).
  • A spec variable to use the values of the common variables for the data set characteristics.

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.