Documentation
PLEASE NOTE: This document applies to v2.19 version and not to the latest stable release v2.20
Documentation for other releases can be found by using the version selector in the top right of any doc page.tempfile
Create temporary files and directories.
This module creates temporary files or directories with optional prefix, suffix, and permission settings. The created path is returned in the output and can be registered for use in subsequent tasks.
Attributes
check_mode:
support: full
Parameters
| Parameter | Required | Type | Values | Description |
|---|---|---|---|---|
| mode | string | Permissions of the temporary file or directory. | ||
| path | string | The parent directory where the temporary object will be created. | ||
| prefix | string | Prefix for the temporary name. | ||
| state | true | string | file directory |
The type of temporary object to create. |
| suffix | string | Suffix for the temporary name (only valid for files). |
Example
- name: Create a temporary directory
tempfile:
state: directory
prefix: myapp_
register: temp_dir
- name: Create a temporary file
tempfile:
state: file
suffix: .txt
register: temp_file
- name: Create temp file with custom mode
tempfile:
state: file
path: /var/tmp
mode: "0600"
register: secure_temp