community.windows.win_toast 模块 – 向 Windows 10 或更高版本主机上已登录用户发送 Toast 窗口通知

注意

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

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

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

要在 playbook 中使用它,请指定:community.windows.win_toast

概要

  • 发送在 Windows 桌面的操作中心区域中显示的警报。

参数

参数

注释

expire

整数

通知过期前的秒数。

默认值: 45

group

字符串

将通知添加到哪个通知组。

默认值: "Powershell"

msg

字符串

通知内显示的消息。

可能包含 \n 来格式化消息使其在操作中心内显示。

默认值: "你好, 世界!"

popup

布尔值

如果为 no,则通知不会弹出,只会出现在操作中心。

选项

  • false

  • true ←(默认)

tag

字符串

添加到通知的标签。

默认值: "Ansible"

title

字符串

通知标题,显示在弹出窗口中。

默认值: "通知 HH:mm"

备注

注意

  • 此模块必须在 Windows 10 或 Server 2016 主机上运行,因此请确保您的 playbook 目标为 Windows 主机,或委派给 Windows 主机。

  • 如果没有已登录用户需要通知,则模块不会失败。

  • 消息仅发送到运行模块的本地主机。

  • 您必须以异步方式运行此模块,否则它将挂起,直到过期时间过去。

另请参阅

另请参阅

community.windows.win_msg

向 Windows 主机上的已登录用户发送消息。

community.windows.win_say

Windows 的文本到语音模块,用于说出消息并可选择播放声音。

示例

- name: Warn logged in users of impending upgrade (note use of async to stop the module from waiting until notification expires).
  community.windows.win_toast:
    expire: 60
    title: System Upgrade Notification
    msg: Automated upgrade about to start.  Please save your work and log off before {{ deployment_start_time }}
  async: 60
  poll: 0

返回值

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

描述

expire_at_utc

字符串

计算得出的通知过期的 UTC 日期时间。

返回: 始终

示例: "2017 7 7 04:50:54"

no_toast_sent_reason

字符串

包含未发送通知原因的文本。

返回: 当检测到没有已登录用户时

示例: "没有已登录的用户需要通知"

sent_localtime

字符串

发送通知时的本地日期时间。

返回: 始终

示例: "2017 7 7 05:45:54"

time_taken

浮点数

模块在远程 Windows 主机上运行所花费的秒数。

返回: 始终

示例: 0.3706631999999997

toast_sent

布尔值

模块是否能够发送 Toast 通知。

返回: 始终

示例: false

作者

  • Jon Hawkesworth (@jhawkesworth)