ibm.ibm_zos_core.zos_encode (1.9.0) — module

Perform encoding operations.

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

Authors: Zhao Lu (@yourfuwa2015), 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

Converts the encoding of characters that are read from a UNIX System Services (USS) file or path, PS (sequential data set), PDS, PDSE, or KSDS (VSAM data set).

Writes the data to a UNIX System Services (USS) file or path, PS (sequential data set), PDS, PDSE, or KSDS (VSAM data set).

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from IBM-1047 to ISO8859-1 for the same file
  zos_encode:
    src: /zos_encode/test.data
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from IBM-1047 to ISO8859-1 to another file with
    backup
  zos_encode:
    src: /zos_encode/test.data
    dest: /zos_encode_out/test.out
    encoding:
      from: IBM-1047
      to: ISO8859-1
    backup: yes
    backup_compress: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from IBM-1047 to ISO8859-1 to a directory
  zos_encode:
    src: /zos_encode/test.data
    dest: /zos_encode_out/
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from all files in a directory to another
    directory
  zos_encode:
    src: /zos_encode/
    dest: /zos_encode_out/
    encoding:
      from: ISO8859-1
      to: IBM-1047
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from a USS file to a sequential data set
  zos_encode:
    src: /zos_encode/test.data
    dest: USER.TEST.PS
    encoding:
      from: IBM-1047
      to: ISO8859-1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from files in a directory to a partitioned
    data set
  zos_encode:
    src: /zos_encode/
    dest: USER.TEST.PDS
    encoding:
      from: ISO8859-1
      to: IBM-1047
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from a USS file to a partitioned data set
    member
  zos_encode:
    src: /zos_encode/test.data
    dest: USER.TEST.PDS(TESTDATA)
    encoding:
      from: ISO8859-1
      to: IBM-1047
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from a sequential data set to a USS file
  zos_encode:
    src: USER.TEST.PS
    dest: /zos_encode/test.data
    encoding:
      from: IBM-1047
      to: ISO8859-1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from a PDS encoding to a USS directory
  zos_encode:
    src: USER.TEST.PDS
    dest: /zos_encode/
    encoding:
      from: IBM-1047
      to: ISO8859-1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from a sequential data set to another
    sequential data set
  zos_encode:
    src: USER.TEST.PS
    dest: USER.TEST1.PS
    encoding:
      from: IBM-1047
      to: ISO8859-1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from a sequential data set to a
    partitioned data set (extended) member
  zos_encode:
    src: USER.TEST.PS
    dest: USER.TEST1.PDS(TESTDATA)
    encoding:
      from: IBM-1047
      to: ISO8859-1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from a USS file to a VSAM data set
  zos_encode:
    src: /zos_encode/test.data
    dest: USER.TEST.VS
    encoding:
      from: ISO8859-1
      to: IBM-1047
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from a VSAM data set to a USS file
  zos_encode:
    src: USER.TEST.VS
    dest: /zos_encode/test.data
    encoding:
      from: IBM-1047
      to: ISO8859-1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from a VSAM data set to a sequential
    data set
  zos_encode:
    src: USER.TEST.VS
    dest: USER.TEST.PS
    encoding:
      from: IBM-1047
      to: ISO8859-1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert file encoding from a sequential data set a VSAM data set
  zos_encode:
    src: USER.TEST.PS
    dest: USER.TEST.VS
    encoding:
      from: ISO8859-1
      to: IBM-1047

Inputs

    
src:
    description:
    - The location can be a UNIX System Services (USS) file or path, PS (sequential data
      set), PDS, PDSE, member of a PDS or PDSE, or KSDS (VSAM data set).
    - The USS path or file must be an absolute pathname.
    - If I(src) is a USS directory, all files will be encoded.
    required: true
    type: str

dest:
    description:
    - The location where the converted characters are output.
    - The destination I(dest) can be a UNIX System Services (USS) file or path, PS (sequential
      data set), PDS, PDSE, member of a PDS or PDSE, or KSDS (VSAM data set).
    - If the length of the PDSE member name used in I(dest) is greater than 8 characters,
      the member name will be truncated when written out.
    - If I(dest) is not specified, the I(src) will be used as the destination and will
      overwrite the I(src) with the character set in the option I(to_encoding).
    - The USS file or path must be an absolute pathname.
    required: false
    type: str

backup:
    default: false
    description:
    - Creates a backup file or backup data set for I(dest), including the timestamp information
      to ensure that you retrieve the original file.
    - I(backup_name) can be used to specify a backup file name if I(backup=true).
    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

encoding:
    description:
    - Specifies which encodings the destination file or data set should be converted from
      and to.
    - Supported character sets rely on the charset conversion utility (iconv) version;
      the most common character sets are supported.
    required: false
    suboptions:
      from:
        default: IBM-1047
        description:
        - The character set of the source I(src).
        required: false
        type: str
      to:
        default: ISO8859-1
        description:
        - The destination I(dest) character set for the output to be written as.
        required: false
        type: str
    type: dict

backup_name:
    description:
    - Specify the USS file name or data set name for the dest backup.
    - If dest is a USS file or path, I(backup_name) must be a file or path name, and the
      USS path or file must be an absolute pathname.
    - If dest is an MVS data set, the I(backup_name) must be an MVS data set name.
    - If I(backup_name) is not provided, the default backup name will be used. The default
      backup name for a USS file or path will be the destination file or path name appended
      with a timestamp, e.g. /path/file_name.2020-04-23-08-32-29-bak.tar. If dest is an
      MVS data set, the default backup name will be a random name generated by IBM Z Open
      Automation Utilities.
    - C(backup_name) will be returned on either success or failure of module execution
      such that data can be retrieved.
    required: false
    type: str

backup_compress:
    default: false
    description:
    - Determines if backups to USS files or paths should be compressed.
    - I(backup_compress) is only used when I(backup=true).
    required: false
    type: bool

Outputs

backup_name:
  description: Name of the backup file created.
  returned: changed and if backup=yes
  sample: /path/file_name.2020-04-23-08-32-29-bak.tar
  type: str
dest:
  description: The name of the output file or data set. If dest is a USS file or path
    and the status has been changed in the conversion, the file status will also be
    returned.
  returned: always
  type: str
src:
  description: The location of the input characters identified in option I(src).
  returned: always
  type: str