sensu / sensu-go-chef

Chef Library Cookbook for Sensu Go
https://sensu.io
MIT License
11 stars 22 forks source link

Create Sensu 2.0 object config LWRPs (e.g. check) #9

Closed portertech closed 5 years ago

portertech commented 6 years ago

Sensu 2.0 object configuration (e.g. check) is done via the Backend API. This cookbook must provide a number of LWRPs for object configuration, one for each Sensu object type. These LWRP must create a Sensu 2.0 object file on disk in a folder named after the object type, e.g. /etc/sensu/checks. Each LWRP must support every documented object configuration attribute for their type, e.g. https://docs.sensu.io/sensu-core/2.0/reference/checks/#check-attributes. When the object file is first written to disk or modified, the LWRPs must execute sensuctl create -f $OBJECT_FILE in order to create/update the Sensu 2.0 object via the Backend API.

Object File Examples

/etc/sensu/checks/cron.json

{
  "type":"Check",
  "spec":{
    "name":"cron",
    "command":"/bin/true",
    "cron":"* * * * *",
    "subscriptions":[
      "test"
    ],
    "publish":true,
    "handlers":[
      "default"
    ],
    "organization":"default",
    "environment":"default"
  }
}

/etc/sensu/handlers/default.json

{
  "type":"Handler",
  "spec":{
    "name":"default",
    "type":"set",
    "handlers":[
      "debug"
    ],
    "organization":"default",
    "environment":"default"
  }
}

LWRP Checklist

(Priority ordered)

webframp commented 6 years ago

PRs up for handler and mutator. Found some weirdness with filter that might just be me not knowing sensu 2 details.

webframp commented 6 years ago

Found the filter weirdness and fixed it. PRs for remaining 3 custom resources are all updated. I can rebase as needed.

Once those are reviewed and merged I'll run another pass through testing to make sure there's solid test coverage for all generated specs.

Then we can discuss next steps and design improvements or refactoring.

webframp commented 6 years ago

sensu_check is still missing proper check_hooks handling, but that should be easy to fix now

webframp commented 6 years ago

Just need confirmation on the object schema for creating a check with check_hooks. Tried this without success:

{
  "type": "check",
  "spec": {
    "check_hooks": {
      "1": [
        "nginx_restart"
      ]
    },
    "command": "/bin/true",
....
webframp commented 6 years ago

Found https://github.com/sensu/sensu-docs/issues/401 while working on this issue

webframp commented 6 years ago
webframp commented 5 years ago

@portertech I think this hook resource is still needed?

webframp commented 5 years ago

I think this work has been completed for a little while now.