ansible / ansible.builtin / v2.9.26 / module / tempfile Creates temporary files and directories | "added in version" 2.3 of ansible.builtin" Authors: Krzysztof Magosa (@krzysztof-magosa) preview | supported by communityansible.builtin.tempfile (v2.9.26) — module
pip
Install with pip install ansible==2.9.26
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.
- name: create temporary build directory tempfile: state: directory suffix: build
- name: create temporary file tempfile: state: file suffix: temp register: tempfile_1
- name: use the registered var and the file module to remove the temporary file file: path: "{{ tempfile_1.path }}" state: absent when: tempfile_1.path is defined
path: description: - Location where temporary file or directory should be created. - If path is not specified, the default system temporary directory will be used. type: path state: choices: - directory - file default: file description: - Whether to create file or directory. type: str prefix: default: ansible. description: - Prefix of file/directory name created by module. type: str suffix: default: '' description: - Suffix of file/directory name created by module. type: str
path: description: Path to created file or directory returned: success sample: /tmp/ansible.bMlvdk type: str