ansible.windows.win_tempfile 模块 – 创建临时文件和目录

注意

此模块是 ansible.windows 集合(版本 2.5.0)的一部分。

如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install ansible.windows

要在 playbook 中使用它,请指定: ansible.windows.win_tempfile

概要

参数

参数

注释

path

别名:dest

path

应在其中创建临时文件或目录的位置。

如果未指定路径,将使用默认系统临时目录 (%TEMP%)。

默认值: "%TEMP%"

prefix

字符串

模块创建的文件/目录名称的前缀。

默认值: "ansible."

state

字符串

是否创建文件或目录。

选项

  • "directory"

  • "file" ← (默认)

suffix

字符串

模块创建的文件/目录名称的后缀。

参见

另请参见

ansible.builtin.tempfile

创建临时文件和目录。

示例

- name: Create temporary build directory
  ansible.windows.win_tempfile:
    state: directory
    suffix: build

- name: Create temporary file
  ansible.windows.win_tempfile:
    state: file
    suffix: temp

返回值

常见返回值记录在此处,以下是此模块独有的字段

描述

path

字符串

创建的文件或目录的绝对路径。

返回: 成功

示例: "C:\\Users\\Administrator\\AppData\\Local\\Temp\\ansible.bMlvdk"

作者

  • Dag Wieers (@dagwieers)