ibm.ibm_zos_core.zos_data_set (1.9.0) — module

Manage data sets

| "added in version" 1.3.0 of ibm.ibm_zos_core"

Authors: Blake Becker (@blakeinate)

Install collection

Install with ansible-galaxy collection install ibm.ibm_zos_core:==1.9.0


Add to requirements.yml

  collections:
    - name: ibm.ibm_zos_core
      version: 1.9.0

Description

Create, delete and set attributes of data sets.

When forcing data set replacement, contents will not be preserved.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a sequential data set if it does not exist
  zos_data_set:
    name: someds.name.here
    type: seq
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a PDS data set if it does not exist
  zos_data_set:
    name: someds.name.here
    type: pds
    space_primary: 5
    space_type: M
    record_format: fba
    record_length: 25
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Attempt to replace a data set if it exists
  zos_data_set:
    name: someds.name.here
    type: pds
    space_primary: 5
    space_type: M
    record_format: u
    record_length: 25
    replace: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Attempt to replace a data set if it exists. If not found in the catalog, check if it is available on volume 222222, and catalog if found.
  zos_data_set:
    name: someds.name.here
    type: pds
    space_primary: 5
    space_type: M
    record_format: u
    record_length: 25
    volumes: "222222"
    replace: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create an ESDS data set if it does not exist
  zos_data_set:
    name: someds.name.here
    type: esds
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a KSDS data set if it does not exist
  zos_data_set:
    name: someds.name.here
    type: ksds
    key_length: 8
    key_offset: 0
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create an RRDS data set with storage class MYDATA if it does not exist
  zos_data_set:
    name: someds.name.here
    type: rrds
    sms_storage_class: mydata
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete a data set if it exists
  zos_data_set:
    name: someds.name.here
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete a data set if it exists. If data set not cataloged, check on volume 222222 for the data set, and then catalog and delete if found.
  zos_data_set:
    name: someds.name.here
    state: absent
    volumes: "222222"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Write a member to an existing PDS; replace if member exists
  zos_data_set:
    name: someds.name.here(mydata)
    type: MEMBER
    replace: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Write a member to an existing PDS; do not replace if member exists
  zos_data_set:
    name: someds.name.here(mydata)
    type: MEMBER
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a member from an existing PDS
  zos_data_set:
    name: someds.name.here(mydata)
    state: absent
    type: MEMBER
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a member from an existing PDS/E by opening with disposition DISP=SHR
  zos_data_set:
    name: someds.name.here(mydata)
    state: absent
    type: MEMBER
    force: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create multiple partitioned data sets and add one or more members to each
  zos_data_set:
    batch:
      - name:  someds.name.here1
        type: PDS
        space_primary: 5
        space_type: M
        record_format: fb
        replace: yes
      - name: someds.name.here1(member1)
        type: MEMBER
      - name: someds.name.here2(member1)
        type: MEMBER
        replace: yes
      - name: someds.name.here2(member2)
        type: MEMBER
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Catalog a data set present on volume 222222 if it is uncataloged.
  zos_data_set:
    name: someds.name.here
    state: cataloged
    volumes: "222222"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Uncatalog a data set if it is cataloged.
  zos_data_set:
    name: someds.name.here
    state: uncataloged
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a data set on volumes 000000 and 222222 if it does not exist.
  zos_data_set:
    name: someds.name.here
    state: present
    volumes:
      - "000000"
      - "222222"

Inputs

    
name:
    description:
    - The name of the data set being managed. (e.g C(USER.TEST))
    - If I(name) is not provided, a randomized data set name will be generated with the
      HLQ matching the module-runners username.
    - Required if I(type=MEMBER) or I(state!=present) and not using I(batch).
    required: false
    type: str

type:
    choices:
    - KSDS
    - ESDS
    - RRDS
    - LDS
    - SEQ
    - PDS
    - PDSE
    - LIBRARY
    - BASIC
    - LARGE
    - MEMBER
    - HFS
    - ZFS
    default: PDS
    description:
    - The data set type to be used when creating a data set. (e.g C(pdse))
    - C(MEMBER) expects to be used with an existing partitioned data set.
    - Choices are case-insensitive.
    required: false
    type: str

batch:
    description:
    - Batch can be used to perform operations on multiple data sets in a single module
      call.
    elements: dict
    required: false
    suboptions:
      block_size:
        description:
        - The block size to use for the data set.
        required: false
        type: int
      directory_blocks:
        description:
        - The number of directory blocks to allocate to the data set.
        required: false
        type: int
      force:
        default: false
        description:
        - Specifies that the data set can be shared with others during a member delete
          operation which results in the data set you are updating to be simultaneously
          updated by others.
        - This is helpful when a data set is being used in a long running process such
          as a started task and you are wanting to delete a member.
        - The I(force=True) option enables sharing of data sets through the disposition
          I(DISP=SHR).
        - The I(force=True) only applies to data set members when I(state=absent) and
          I(type=MEMBER).
        required: false
        type: bool
      key_length:
        description:
        - The key length to use when creating a KSDS data set.
        - I(key_length) is required when I(type=KSDS).
        - I(key_length) should only be provided when I(type=KSDS)
        required: false
        type: int
      key_offset:
        description:
        - The key offset to use when creating a KSDS data set.
        - I(key_offset) is required when I(type=KSDS).
        - I(key_offset) should only be provided when I(type=KSDS)
        required: false
        type: int
      name:
        description:
        - The name of the data set being managed. (e.g C(USER.TEST))
        - If I(name) is not provided, a randomized data set name will be generated with
          the HLQ matching the module-runners username.
        - Required if I(type=MEMBER) or I(state!=present)
        required: false
        type: str
      record_format:
        choices:
        - FB
        - VB
        - FBA
        - VBA
        - U
        - F
        default: FB
        description:
        - The format of the data set. (e.g C(FB))
        - Choices are case-insensitive.
        - When I(type=KSDS), I(type=ESDS), I(type=RRDS), I(type=LDS) or I(type=ZFS) then
          I(record_format=None), these types do not have a default I(record_format).
        required: false
        type: str
      record_length:
        description:
        - The length, in bytes, of each record in the data set.
        - For variable data sets, the length must include the 4-byte prefix area.
        - 'Defaults vary depending on format: If FB/FBA 80, if VB/VBA 137, if U 0.'
        required: false
        type: int
      replace:
        default: false
        description:
        - When I(replace=True), and I(state=present), existing data set matching I(name)
          will be replaced.
        - 'Replacement is performed by deleting the existing data set and creating a new
          data set with the same name and desired attributes. Since the existing data
          set will be deleted prior to creating the new data set, no data set will exist
          if creation of the new data set fails.

          '
        - If I(replace=True), all data in the original data set will be lost.
        required: false
        type: bool
      sms_data_class:
        description:
        - The data class for an SMS-managed dataset.
        - Optional for SMS-managed datasets that do not match an SMS-rule.
        - Not valid for datasets that are not SMS-managed.
        - Note that all non-linear VSAM datasets are SMS-managed.
        required: false
        type: str
      sms_management_class:
        description:
        - The management class for an SMS-managed dataset.
        - Optional for SMS-managed datasets that do not match an SMS-rule.
        - Not valid for datasets that are not SMS-managed.
        - Note that all non-linear VSAM datasets are SMS-managed.
        required: false
        type: str
      sms_storage_class:
        description:
        - The storage class for an SMS-managed dataset.
        - Required for SMS-managed datasets that do not match an SMS-rule.
        - Not valid for datasets that are not SMS-managed.
        - Note that all non-linear VSAM datasets are SMS-managed.
        required: false
        type: str
      space_primary:
        default: 5
        description:
        - The amount of primary space to allocate for the dataset.
        - The unit of space used is set using I(space_type).
        required: false
        type: int
      space_secondary:
        default: 3
        description:
        - The amount of secondary space to allocate for the dataset.
        - The unit of space used is set using I(space_type).
        required: false
        type: int
      space_type:
        choices:
        - K
        - M
        - G
        - CYL
        - TRK
        default: M
        description:
        - The unit of measurement to use when defining primary and secondary space.
        - Valid units of size are C(K), C(M), C(G), C(CYL), and C(TRK).
        required: false
        type: str
      state:
        choices:
        - present
        - absent
        - cataloged
        - uncataloged
        default: present
        description:
        - The final state desired for specified data set.
        - 'If I(state=absent) and the data set does not exist on the managed node, no
          action taken, module completes successfully with I(changed=False).

          '
        - 'If I(state=absent) and the data set does exist on the managed node, remove
          the data set, module completes successfully with I(changed=True).

          '
        - 'If I(state=absent) and I(type=MEMBER) and I(force=True), the data set will
          be opened with I(DISP=SHR) such that the entire data set can be accessed by
          other processes while the specified member is deleted.

          '
        - 'If I(state=absent) and I(volumes) is provided, and the data set is not found
          in the catalog, the module attempts to perform catalog using supplied I(name)
          and I(volumes). If the attempt to catalog the data set catalog is successful,
          then the data set is removed. Module completes successfully with I(changed=True).

          '
        - 'If I(state=absent) and I(volumes) is provided, and the data set is not found
          in the catalog, the module attempts to perform catalog using supplied I(name)
          and I(volumes). If the attempt to catalog the data set catalog fails, then no
          action is taken. Module completes successfully with I(changed=False).

          '
        - 'If I(state=absent) and I(volumes) is provided, and the data set is found in
          the catalog, the module compares the catalog volume attributes to the provided
          I(volumes). If they volume attributes are different, the cataloged data set
          will be uncataloged temporarily while the requested data set be deleted is cataloged.
          The module will catalog the original data set on completion, if the attempts
          to catalog fail, no action is taken. Module completes successfully with I(changed=False).

          '
        - 'If I(state=present) and the data set does not exist on the managed node, create
          and catalog the data set, module completes successfully with I(changed=True).

          '
        - 'If I(state=present) and I(replace=True) and the data set is present on the
          managed node the existing data set is deleted, and a new data set is created
          and cataloged with the desired attributes, module completes successfully with
          I(changed=True).

          '
        - 'If I(state=present) and I(replace=False) and the data set is present on the
          managed node, no action taken, module completes successfully with I(changed=False).

          '
        - 'If I(state=present) and I(type=MEMBER) and the member does not exist in the
          data set, create a member formatted to store data, module completes successfully
          with I(changed=True). Note, a PDSE does not allow a mixture of formats such
          that there is executables (program objects) and data. The member created is
          formatted to store data, not an executable.

          '
        - 'If I(state=cataloged) and I(volumes) is provided and the data set is already
          cataloged, no action taken, module completes successfully with I(changed=False).

          '
        - 'If I(state=cataloged) and I(volumes) is provided and the data set is not cataloged,
          module attempts to perform catalog using supplied I(name) and I(volumes). If
          the attempt to catalog the data set catalog is successful, module completes
          successfully with I(changed=True).

          '
        - 'If I(state=cataloged) and I(volumes) is provided and the data set is not cataloged,
          module attempts to perform catalog using supplied I(name) and I(volumes). If
          the attempt to catalog the data set catalog fails, returns failure with I(changed=False).

          '
        - 'If I(state=uncataloged) and the data set is not found, no action taken, module
          completes successfully with I(changed=False).

          '
        - 'If I(state=uncataloged) and the data set is found, the data set is uncataloged,
          module completes successfully with I(changed=True).

          '
        required: false
        type: str
      type:
        choices:
        - KSDS
        - ESDS
        - RRDS
        - LDS
        - SEQ
        - PDS
        - PDSE
        - LIBRARY
        - BASIC
        - LARGE
        - MEMBER
        - HFS
        - ZFS
        default: PDS
        description:
        - The data set type to be used when creating a data set. (e.g C(PDSE))
        - C(MEMBER) expects to be used with an existing partitioned data set.
        - Choices are case-insensitive.
        required: false
        type: str
      volumes:
        aliases:
        - volume
        description:
        - 'If cataloging a data set, I(volumes) specifies the name of the volume(s) where
          the data set is located.

          '
        - 'If creating a data set, I(volumes) specifies the volume(s) where the data set
          should be created.

          '
        - 'If I(volumes) is provided when I(state=present), and the data set is not found
          in the catalog, L(zos_data_set,./zos_data_set.html) will check the volume table
          of contents to see if the data set exists. If the data set does exist, it will
          be cataloged.

          '
        - 'If I(volumes) is provided when I(state=absent) and the data set is not found
          in the catalog, L(zos_data_set,./zos_data_set.html) will check the volume table
          of contents to see if the data set exists. If the data set does exist, it will
          be cataloged and promptly removed from the system.

          '
        - I(volumes) is required when I(state=cataloged).
        - Accepts a string when using a single volume and a list of strings when using
          multiple.
        required: false
        type: raw
    type: list

force:
    default: false
    description:
    - Specifies that the data set can be shared with others during a member delete operation
      which results in the data set you are updating to be simultaneously updated by others.
    - This is helpful when a data set is being used in a long running process such as
      a started task and you are wanting to delete a member.
    - The I(force=True) option enables sharing of data sets through the disposition I(DISP=SHR).
    - The I(force=True) only applies to data set members when I(state=absent) and I(type=MEMBER).
    required: false
    type: bool

state:
    choices:
    - present
    - absent
    - cataloged
    - uncataloged
    default: present
    description:
    - The final state desired for specified data set.
    - 'If I(state=absent) and the data set does not exist on the managed node, no action
      taken, module completes successfully with I(changed=False).

      '
    - 'If I(state=absent) and the data set does exist on the managed node, remove the
      data set, module completes successfully with I(changed=True).

      '
    - 'If I(state=absent) and I(type=MEMBER) and I(force=True), the data set will be opened
      with I(DISP=SHR) such that the entire data set can be accessed by other processes
      while the specified member is deleted.

      '
    - 'If I(state=absent) and I(volumes) is provided, and the data set is not found in
      the catalog, the module attempts to perform catalog using supplied I(name) and I(volumes).
      If the attempt to catalog the data set catalog is successful, then the data set
      is removed. Module completes successfully with I(changed=True).

      '
    - 'If I(state=absent) and I(volumes) is provided, and the data set is not found in
      the catalog, the module attempts to perform catalog using supplied I(name) and I(volumes).
      If the attempt to catalog the data set catalog fails, then no action is taken. Module
      completes successfully with I(changed=False).

      '
    - 'If I(state=absent) and I(volumes) is provided, and the data set is found in the
      catalog, the module compares the catalog volume attributes to the provided I(volumes).
      If the volume attributes are different, the cataloged data set will be uncataloged
      temporarily while the requested data set be deleted is cataloged. The module will
      catalog the original data set on completion, if the attempts to catalog fail, no
      action is taken. Module completes successfully with I(changed=False).

      '
    - 'If I(state=present) and the data set does not exist on the managed node, create
      and catalog the data set, module completes successfully with I(changed=True).

      '
    - 'If I(state=present) and I(replace=True) and the data set is present on the managed
      node the existing data set is deleted, and a new data set is created and cataloged
      with the desired attributes, module completes successfully with I(changed=True).

      '
    - 'If I(state=present) and I(replace=False) and the data set is present on the managed
      node, no action taken, module completes successfully with I(changed=False).

      '
    - 'If I(state=present) and I(type=MEMBER) and the member does not exist in the data
      set, create a member formatted to store data, module completes successfully with
      I(changed=True). Note, a PDSE does not allow a mixture of formats such that there
      is executables (program objects) and data. The member created is formatted to store
      data, not an executable.

      '
    - 'If I(state=cataloged) and I(volumes) is provided and the data set is already cataloged,
      no action taken, module completes successfully with I(changed=False).

      '
    - 'If I(state=cataloged) and I(volumes) is provided and the data set is not cataloged,
      module attempts to perform catalog using supplied I(name) and I(volumes). If the
      attempt to catalog the data set catalog is successful, module completes successfully
      with I(changed=True).

      '
    - 'If I(state=cataloged) and I(volumes) is provided and the data set is not cataloged,
      module attempts to perform catalog using supplied I(name) and I(volumes). If the
      attempt to catalog the data set catalog fails, returns failure with I(changed=False).

      '
    - 'If I(state=uncataloged) and the data set is not found, no action taken, module
      completes successfully with I(changed=False).

      '
    - 'If I(state=uncataloged) and the data set is found, the data set is uncataloged,
      module completes successfully with I(changed=True).

      '
    required: false
    type: str

replace:
    default: false
    description:
    - When I(replace=True), and I(state=present), existing data set matching I(name) will
      be replaced.
    - 'Replacement is performed by deleting the existing data set and creating a new data
      set with the same name and desired attributes. Since the existing data set will
      be deleted prior to creating the new data set, no data set will exist if creation
      of the new data set fails.

      '
    - If I(replace=True), all data in the original data set will be lost.
    required: false
    type: bool

tmp_hlq:
    description:
    - Override the default high level qualifier (HLQ) for temporary and backup datasets.
    - The default HLQ is the Ansible user used to execute the module and if that is not
      available, then the value C(TMPHLQ) is used.
    required: false
    type: str

volumes:
    aliases:
    - volume
    description:
    - 'If cataloging a data set, I(volumes) specifies the name of the volume(s) where
      the data set is located.

      '
    - 'If creating a data set, I(volumes) specifies the volume(s) where the data set should
      be created.

      '
    - 'If I(volumes) is provided when I(state=present), and the data set is not found
      in the catalog, L(zos_data_set,./zos_data_set.html) will check the volume table
      of contents to see if the data set exists. If the data set does exist, it will be
      cataloged.

      '
    - 'If I(volumes) is provided when I(state=absent) and the data set is not found in
      the catalog, L(zos_data_set,./zos_data_set.html) will check the volume table of
      contents to see if the data set exists. If the data set does exist, it will be cataloged
      and promptly removed from the system.

      '
    - I(volumes) is required when I(state=cataloged).
    - Accepts a string when using a single volume and a list of strings when using multiple.
    required: false
    type: raw

block_size:
    description:
    - The block size to use for the data set.
    required: false
    type: int

key_length:
    description:
    - The key length to use when creating a KSDS data set.
    - I(key_length) is required when I(type=KSDS).
    - I(key_length) should only be provided when I(type=KSDS)
    required: false
    type: int

key_offset:
    description:
    - The key offset to use when creating a KSDS data set.
    - I(key_offset) is required when I(type=KSDS).
    - I(key_offset) should only be provided when I(type=KSDS)
    required: false
    type: int

space_type:
    choices:
    - K
    - M
    - G
    - CYL
    - TRK
    default: M
    description:
    - The unit of measurement to use when defining primary and secondary space.
    - Valid units of size are C(K), C(M), C(G), C(CYL), and C(TRK).
    required: false
    type: str

record_format:
    choices:
    - FB
    - VB
    - FBA
    - VBA
    - U
    - F
    default: FB
    description:
    - The format of the data set. (e.g C(FB))
    - Choices are case-insensitive.
    - When I(type=KSDS), I(type=ESDS), I(type=RRDS), I(type=LDS) or I(type=ZFS) then I(record_format=None),
      these types do not have a default I(record_format).
    required: false
    type: str

record_length:
    description:
    - The length, in bytes, of each record in the data set.
    - For variable data sets, the length must include the 4-byte prefix area.
    - 'Defaults vary depending on format: If FB/FBA 80, if VB/VBA 137, if U 0.'
    required: false
    type: int

space_primary:
    default: 5
    description:
    - The amount of primary space to allocate for the dataset.
    - The unit of space used is set using I(space_type).
    required: false
    type: int

sms_data_class:
    description:
    - The data class for an SMS-managed dataset.
    - Optional for SMS-managed datasets that do not match an SMS-rule.
    - Not valid for datasets that are not SMS-managed.
    - Note that all non-linear VSAM datasets are SMS-managed.
    required: false
    type: str

space_secondary:
    default: 3
    description:
    - The amount of secondary space to allocate for the dataset.
    - The unit of space used is set using I(space_type).
    required: false
    type: int

directory_blocks:
    description:
    - The number of directory blocks to allocate to the data set.
    required: false
    type: int

sms_storage_class:
    description:
    - The storage class for an SMS-managed dataset.
    - Required for SMS-managed datasets that do not match an SMS-rule.
    - Not valid for datasets that are not SMS-managed.
    - Note that all non-linear VSAM datasets are SMS-managed.
    required: false
    type: str

sms_management_class:
    description:
    - The management class for an SMS-managed dataset.
    - Optional for SMS-managed datasets that do not match an SMS-rule.
    - Not valid for datasets that are not SMS-managed.
    - Note that all non-linear VSAM datasets are SMS-managed.
    required: false
    type: str

Outputs

names:
  description: The data set names, including temporary generated data set names, in
    the order provided to the module.
  elements: str
  returned: always
  type: list