ibm.ibm_zos_zosmf.zmf_file (3.0.1) — module

Manage z/OS USS file or directory

| "added in version" 2.9 of ibm.ibm_zos_zosmf"

Authors: Yang Cao (@zosmf-Young), Yun Juan Yang (@zosmf-Robyn)

preview | supported by community

Install collection

Install with ansible-galaxy collection install ibm.ibm_zos_zosmf:==3.0.1


Add to requirements.yml

  collections:
    - name: ibm.ibm_zos_zosmf
      version: 3.0.1

Description

Create, delete and operate on a z/OS UNIX System Services (USS) file or a directory on z/OS system.

The available operations include rename, change mode, change owner and change tag.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a USS file /etc/profile with default mode 755
  zmf_file:
    zmf_host: "sample.ibm.com"
    file_path: "/etc/profile"
    file_state: "file"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a directory /etc/some_directory with mode 644
  zmf_file:
    zmf_host: "sample.ibm.com"
    file_path: "/etc/some_directory"
    file_state: "directory"
    file_mode:
        mode: "644"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Change the permissions, owner, group and tag of a USS file /etc/profile
  zmf_file:
    zmf_host: "sample.ibm.com"
    file_path: "/etc/profile"
    file_state: "file"
    file_mode:
        mode: "644"
    file_owner:
        owner: "500000"
        group: "0"
    file_tag:
        tag: "text"
        codeset: "IBM-1047"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Change the permissions of a directory /etc/some_directory, and recursively change its owner, group and tag
  zmf_file:
    zmf_host: "sample.ibm.com"
    file_path: "/etc/some_directory"
    file_state: "directory"
    file_mode:
        mode: "644"
        recursive: false
    file_owner:
        owner: "500000"
        group: "0"
        recursive: true
    file_tag:
        tag: "text"
        codeset: "IBM-1047"
        recursive: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Rename a USS file /etc/profile to /etc/profile.bak
  zmf_file:
    zmf_host: "sample.ibm.com"
    file_path: "/etc/profile"
    file_state: "file"
    file_new_name: "/etc/profile.bak"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete a USS file /etc/profile
  zmf_file:
    zmf_host: "sample.ibm.com"
    file_path: "/etc/profile"
    file_state: "absent"

Inputs

    
zmf_crt:
    default: null
    description:
    - Location of the PEM-formatted certificate chain file to be used for HTTPS client
      authentication.
    - If I(zmf_credential) is supplied, I(zmf_crt) is ignored.
    - If I(zmf_credential) is not supplied, I(zmf_crt) is required when I(zmf_user) and
      I(zmf_password) are not supplied.
    required: false
    type: str

zmf_key:
    default: null
    description:
    - Location of the PEM-formatted file with your private key to be used for HTTPS client
      authentication.
    - If I(zmf_credential) is supplied, I(zmf_key) is ignored.
    - If I(zmf_credential) is not supplied, I(zmf_key) is required when I(zmf_user) and
      I(zmf_password) are not supplied.
    required: false
    type: str

file_tag:
    default: null
    description:
    - Indicates the function change tag.
    - This variable only take effects when I(file_state=file) or I(file_state=directory).
    required: false
    suboptions:
      codeset:
        default: null
        description:
        - Specifies the coded character set in which text data is encoded, such as ASCII
          or EBCDIC.
        - "For example, the code set for ASCII is ISO8859\u20131; the code set for EBCDIC\
          \ is IBM-1047."
        - This variable only take effects when I(tag=mixed) or I(tag=text).
        - This variable is required when I(tag=text).
        required: false
        type: str
      recursive:
        default: false
        description:
        - This variable only take effects when I(file_state=directory).
        - When I(recursive=true), tags all the files and subdirectories in that directory
          (chtag -R).
        required: false
        type: bool
      tag:
        choices:
        - mixed
        - text
        - binary
        - absent
        description:
        - The type of file tag.
        - If I(tag=absent), any existing file tag is removed.
        required: true
        type: str
    type: dict

zmf_host:
    default: null
    description:
    - Hostname of the z/OSMF server.
    - If I(zmf_credential) is supplied, I(zmf_host) is ignored.
    - If I(zmf_credential) is not supplied, I(zmf_host) is required.
    required: false
    type: str

zmf_port:
    default: null
    description:
    - Port number of the z/OSMF server.
    - If I(zmf_credential) is supplied, I(zmf_port) is ignored.
    required: false
    type: int

zmf_user:
    default: null
    description:
    - User name to be used for authenticating with z/OSMF server.
    - If I(zmf_credential) is supplied, I(zmf_user) is ignored.
    - If I(zmf_credential) is not supplied, I(zmf_user) is required when I(zmf_crt) and
      I(zmf_key) are not supplied.
    - If I(zmf_credential) is not supplied and I(zmf_crt) and I(zmf_key) are supplied,
      I(zmf_user) and I(zmf_password) are ignored.
    required: false
    type: str

file_mode:
    default: null
    description:
    - Specifies the permission the resulting USS file or directory should have.
    - This variable only take effects when I(file_state=file) or I(file_state=directory).
    - If I(file_path) does not exist, this value is used in creating I(file_path). If
      this value is omitted, 755 is used by default.
    - If I(file_path) exists, this value is used in changing mode of I(file_path).
    required: false
    suboptions:
      mode:
        description:
        - The value of file mode bits.
        - This value could be either the POSIX symbolic form (e.g., C(RWXRW-RW-)) or octal
          value (e.g., C(755)).
        required: true
        type: str
      recursive:
        default: false
        description:
        - This variable only take effects when I(file_state=directory).
        - When I(recursive=true), the file mode bits of the directory and all files in
          the file hierarchy below it are changed (chmod -R).
        required: false
        type: bool
    type: dict

file_path:
    description:
    - Path to the USS file or directory being managed.
    - This variable must consist of a fully qualified path and file or directory name.
      For example, C(/etc/profile).
    - The module will fail if parent directory of I(file_path) does not exist or is a
      read-only file system.
    required: true
    type: str

file_owner:
    default: null
    description:
    - Indicates the function change owner.
    - This variable only take effects when I(file_state=file) or I(file_state=directory).
    required: false
    suboptions:
      group:
        default: null
        description: The group ID or GID.
        required: false
        type: str
      owner:
        description: The user ID or UID.
        required: true
        type: str
      recursive:
        default: false
        description:
        - This variable only take effects when I(file_state=directory).
        - When I(recursive=true), changes all the files and subdirectories in that directory
          to belong to the specified owner and group (chown -R).
        required: false
        type: bool
    type: dict

file_state:
    choices:
    - file
    - directory
    - absent
    description:
    - The final state desired for specified USS file or directory.
    - 'If I(file_state=file) and I(file_path) does not exist, I(file_path) is created
      as a USS file, the module completes successfully with C(changed=True).

      '
    - 'If I(file_state=directory) and I(file_path) does not exist, I(file_path) is created
      as a directory, the module completes successfully with C(changed=True).

      '
    - 'If I(file_state=file) or I(file_state=directory), and I(file_path) exists, I(file_path)
      is modified with other supplied variables (e.g., I(file_mode)), the module completes
      successfully with C(changed=True).

      '
    - 'If I(file_state=file) or I(file_state=directory), and I(file_path) exists, no action
      taken if no other variables are supplied (e.g., I(file_mode)), the module completes
      successfully with C(changed=False).

      '
    - 'If I(file_state=absent) and I(file_path) does not exist, no action taken, the module
      completes successfully with C(changed=False).

      '
    - 'If I(file_state=absent) and I(file_path) exists, the existing I(file_path) is deleted,
      the module completes successfully with C(changed=True).

      '
    required: true
    type: str

zmf_password:
    default: null
    description:
    - Password to be used for authenticating with z/OSMF server.
    - If I(zmf_credential) is supplied, I(zmf_password) is ignored.
    - If I(zmf_credential) is not supplied, I(zmf_password) is required when I(zmf_crt)
      and I(zmf_key) are not supplied.
    - If I(zmf_credential) is not supplied and I(zmf_crt) and I(zmf_key) are supplied,
      I(zmf_user) and I(zmf_password) are ignored.
    required: false
    type: str

file_new_name:
    default: null
    description:
    - Specifies the new name of the USS file or directory.
    - This variable only take effects when I(file_state=file) or I(file_state=directory).
    required: false
    type: str

zmf_credential:
    default: null
    description:
    - Authentication credentials, returned by module C(zmf_authenticate), for the successful
      authentication with z/OSMF server.
    - If I(zmf_credential) is supplied, I(zmf_host), I(zmf_port), I(zmf_user), I(zmf_password),
      I(zmf_crt) and I(zmf_key) are ignored.
    required: false
    suboptions:
      LtpaToken2:
        default: null
        description:
        - The value of Lightweight Third Party Access (LTPA) token, which supports strong
          encryption.
        - If I(jwtToken) is not supplied, I(LtpaToken2) is required.
        required: false
        type: str
      jwtToken:
        default: null
        description:
        - The value of JSON Web token, which supports strong encryption.
        - If I(LtpaToken2) is not supplied, I(jwtToken) is required.
        required: false
        type: str
      zmf_host:
        description: Hostname of the z/OSMF server.
        required: true
        type: str
      zmf_port:
        default: null
        description: Port number of the z/OSMF server.
        required: false
        type: int
    type: dict

Outputs

changed:
  description: Indicates if any change is made during the module operation.
  returned: always
  type: bool
file_properties:
  description: The properties of the present USS file or directory.
  returned: on success
  sample:
    gid: 0
    group: OPERATOR
    mode: -rwxr-xr-x
    mtime: '2021-01-21T01:24:04'
    name: profile
    size: 0
    tag: t IBM-1047    T=on  /etc/profile
    uid: 500000
    user: IBMUSER
  type: dict
message:
  description: The output message generated by the module to indicate whether the
    USS file or directory is successfully created, deleted, or updated.
  returned: on success
  sample:
    sample1: The file /etc/profile is created successfully.
    sample2: The directory /etc/some_directory is deleted successfully.
    sample3: The file or directory /etc/profile does not exist.
    sample4: The file /etc/profile already exists.
    sample5: The file /etc/profile is updated successfully.
    sample6: The file /etc/profile is successfully renamed to /etc/profile.bak.
  type: str