community.general.splunk 回调 – 将任务结果事件发送到 Splunk HTTP 事件收集器
注意
此回调插件是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。 它不包含在 ansible-core
中。 要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。 您需要进一步的要求才能使用此回调插件,请参阅 要求 以了解详细信息。
要在 playbook 中使用它,请指定:community.general.splunk
。
回调插件
此插件是一个 **通知回调**。它将 playbook 运行的信息发送到其他应用程序、服务或系统。有关回调插件的更多信息,请参阅 回调插件。
概要
此回调插件会将任务结果作为 JSON 格式的事件发送到 Splunk HTTP 收集器。
配套的 Splunk 监控和诊断应用程序可在此处获得:https://splunkbase.splunk.com/app/4023/。
感谢“Ryan Currah (@ryancurrah)”提供了原始源代码,此代码基于该源代码。
要求
在执行此回调的本地控制器节点上需要以下要求。
将此回调插件列入白名单
在 Splunk 中创建一个 HTTP 事件收集器
在
ansible.cfg
中定义 URL 和令牌
参数
参数 |
注释 |
---|---|
是否在发送到 Splunk HTTP 收集器的事件中包含毫秒作为生成的时间戳字段的一部分。 选择
配置
|
|
是否验证与 HEC 连接的证书。 除非您确定没有人可以拦截此插件和 HEC 之间的连接,否则不建议设置为 选择
配置
|
示例
examples: >
To enable, add this to your ansible.cfg file in the defaults block
[defaults]
callback_whitelist = community.general.splunk
Set the environment variable
export SPLUNK_URL=http://mysplunkinstance.datapaas.io:8088/services/collector/event
export SPLUNK_AUTHTOKEN=f23blad6-5965-4537-bf69-5b5a545blabla88
Set the ansible.cfg variable in the callback_splunk block
[callback_splunk]
url = http://mysplunkinstance.datapaas.io:8088/services/collector/event
authtoken = f23blad6-5965-4537-bf69-5b5a545blabla88