community.general.sensu_handler module – Manages Sensu handler configuration
Note
This module is part of the community.general collection (version 9.5.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.sensu_handler
.
Synopsis
Manages Sensu handler configuration
For more information, refer to the Sensu documentation: https://sensuapp.org/docs/latest/reference/handlers.html
Parameters
Parameter |
Comments |
---|---|
The handler command to be executed. The event data is passed to the process via STDIN. NOTE: the command attribute is only required for Pipe handlers (i.e. handlers configured with “type”: “pipe”). |
|
The Sensu event filter (name) to use when filtering events for the handler. |
|
An array of Sensu event filters (names) to use when filtering events for the handler. Each array item must be a string. |
|
If events in the flapping state should be handled. Choices:
|
|
If events matching one or more silence entries should be handled. Choices:
|
|
An array of Sensu event handlers (names) to use for events using the handler set. NOTE: the handlers attribute is only required for handler sets (i.e. handlers configured with “type”: “set”). |
|
The Sensu event mutator (name) to use to mutate event data for the handler. |
|
A unique name for the handler. The name cannot contain special characters or spaces. |
|
The pipe definition scope, used to configure the Sensu transport pipe. NOTE: the pipe attribute is only required for Transport handlers (i.e. handlers configured with “type”: “transport”). |
|
An array of check result severities the handler will handle. NOTE: event resolution bypasses this filtering. Example: [ ‘warning’, ‘critical’, ‘unknown’ ]. |
|
The socket definition scope, used to configure the TCP/UDP handler socket. NOTE: the socket attribute is only required for TCP/UDP handlers (i.e. handlers configured with “type”: “tcp” or “type”: “udp”). |
|
Whether the handler should be present or not Choices:
|
|
The handler execution duration timeout in seconds (hard stop). Only used by pipe and tcp handler types. Default: |
|
The handler type Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Notes
Note
Check mode is supported
Examples
# Configure a handler that sends event data as STDIN (pipe)
- name: Configure IRC Sensu handler
community.general.sensu_handler:
name: "irc_handler"
type: "pipe"
command: "/usr/local/bin/notify-irc.sh"
severities:
- "ok"
- "critical"
- "warning"
- "unknown"
timeout: 15
notify:
- Restart sensu-client
- Restart sensu-server
# Delete a handler
- name: Delete IRC Sensu handler
community.general.sensu_handler:
name: "irc_handler"
state: "absent"
# Example of a TCP handler
- name: Configure TCP Sensu handler
community.general.sensu_handler:
name: "tcp_handler"
type: "tcp"
timeout: 30
socket:
host: "10.0.1.99"
port: 4444
register: handler
notify:
- Restart sensu-client
- Restart sensu-server
- name: Secure Sensu handler configuration file
ansible.builtin.file:
path: "{{ handler['file'] }}"
owner: "sensu"
group: "sensu"
mode: "0600"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Effective handler configuration, when state is present Returned: success Sample: |
|
Path to the handler configuration file Returned: success Sample: |
|
Name of the handler Returned: success Sample: |