sensu.sensu_go.hook (0.7.8) — module

Manages Sensu hooks

Authors: Paul Arthur (@flowerysong), Aljaz Kosir (@aljazkosir), Miha Plesko (@miha-plesko), Tadej Borovsak (@tadeboro)

preview | supported by XLAB Steampunk

Install collection

Install with ansible-galaxy collection install sensu.sensu_go:==0.7.8


Add to requirements.yml

  collections:
    - name: sensu.sensu_go
      version: 0.7.8

Description

For more information, refer to the Sensu documentation at U(https://docs.sensu.io/sensu-go/latest/reference/hooks/)

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Rudimentary auto-remediation hook
  hook:
    auth:
      url: http://localhost:8080
    name: restart_nginx
    command: sudo systemctl start nginx
    timeout: 60
    stdin: false
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Capture the process tree

  hook:
    auth:
      url: http://localhost:8080
    name: process_tree
    command: ps aux
    timeout: 60
    stdin: false

Inputs

    
auth:
    description:
    - Authentication parameters. Can define each of them with ENV as well.
    suboptions:
      namespace:
        default: default
        description:
        - RBAC namespace to operate in. If this is not set the value of the SENSU_NAMESPACE
          environment variable will be checked.
        type: str
      password:
        default: P@ssw0rd!
        description:
        - The Sensu user's password. If this is not set the value of the SENSU_PASSWORD
          environment variable will be checked.
        type: str
      url:
        default: http://localhost:8080
        description:
        - Location of the Sensu backend API. If this is not set the value of the SENSU_URL
          environment variable will be checked.
        type: str
      user:
        default: admin
        description:
        - The username to use for connecting to the Sensu API. If this is not set the
          value of the SENSU_USER environment variable will be checked.
        type: str
    type: dict

name:
    description:
    - The Sensu object's name.
    required: true
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Target state of the Sensu object.
    type: str

stdin:
    description:
    - Controls whether Sensu writes serialized JSON data to the process's stdin.
    type: bool

labels:
    description:
    - Custom metadata fields that can be accessed within Sensu, as key/value pairs.
    type: dict

command:
    description:
    - Command to run when the hook is triggered.
    type: str

timeout:
    description:
    - The hook execution duration timeout in seconds (hard stop).
    type: int

annotations:
    description:
    - Custom metadata fields with fewer restrictions, as key/value pairs.
    - These are preserved by Sensu but not accessible as tokens or identifiers, and are
      mainly intended for use with external tools.
    type: dict

runtime_assets:
    description:
    - List of runtime assets required to run the check
    type: list

Outputs

object:
  description: object representing Sensu hook
  returned: success
  type: dict