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 桌面的操作中心区域中显示的警报。
参数
参数 |
注释 |
---|---|
通知过期前的秒数。 默认值: |
|
将通知添加到哪个通知组。 默认值: |
|
通知内显示的消息。 可能包含 \n 来格式化消息使其在操作中心内显示。 默认值: |
|
如果为 选项
|
|
添加到通知的标签。 默认值: |
|
通知标题,显示在弹出窗口中。 默认值: |
备注
注意
此模块必须在 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
返回值
常见的返回值在此处记录 此处,以下是此模块独有的字段
键 |
描述 |
---|---|
计算得出的通知过期的 UTC 日期时间。 返回: 始终 示例: |
|
包含未发送通知原因的文本。 返回: 当检测到没有已登录用户时 示例: |
|
发送通知时的本地日期时间。 返回: 始终 示例: |
|
模块在远程 Windows 主机上运行所花费的秒数。 返回: 始终 示例: |
|
模块是否能够发送 Toast 通知。 返回: 始终 示例: |