ansible.builtin.tempfile (v2.6.0) — module

Creates temporary files and directories.

| "added in version" 2.3 of ansible.builtin"

Authors: Krzysztof Magosa

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.6.0

Description

The C(tempfile) module creates temporary files and directories. C(mktemp) command takes different parameters on various systems, this module helps to avoid troubles related to that. Files/directories created by module are accessible only by creator. In case you need to make them world-accessible you need to use M(file) module.

For Windows targets, use the M(win_tempfile) module instead.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: create temporary build directory
  tempfile:
    state: directory
    suffix: build
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: create temporary file
  tempfile:
    state: file
    suffix: temp

Inputs

    
path:
    description:
    - Location where temporary file or directory should be created. If path is not specified
      default system temporary directory will be used.

state:
    choices:
    - directory
    - file
    default: file
    description:
    - Whether to create file or directory.

prefix:
    default: ansible.
    description:
    - Prefix of file/directory name created by module.

suffix:
    default: ''
    description:
    - Suffix of file/directory name created by module.

Outputs

path:
  description: Path to created file or directory
  returned: success
  sample: /tmp/ansible.bMlvdk
  type: string