Let's discuss: best practise for templating Sensu resource definitions

Okay,

tl;dr

I’m looking at adding some sort of yaml templating to the Sensu Flow monitoring as code reference implementation and I’m trying to decide on what yaml templating engine makes the most sense as a best practice for Sensu resources. Is anyone out there already using a yaml templating system for this in their own workflows?

background:

So I’ve had several side bar discussion now with people who want to see something like “Helm for Sensu” that allows teams to construct resource definitions from a template, so they only need to define just a few elements that need to change instead of defining the whole resource to ensure the final rendered yaml resource meet required internal policy for common attributes (like annotations,secrets etc…)

Unfortunately Helm itself is Kubernetes specific. You can’t easily use Helm’s templating engine to render arbitrary yaml, Helm renders directly into k8s api.

But there are yaml templating engines out there that will work for arbitrary yaml. I want to pick one approach and support it in the Sensu Flow implementation. So far i’m leaning towards ytt, but I’d like to know if any is successfully using another yaml templating engine already.

isn’t there a terraform provider to accomplish this?

i just use bash scripting to template resource definitions. so i’d do the same thing for other resources. checks would have name, command, handlers, assets, subscriptions, secrets, etc…

it’s basic, but it does the trick.

create_resource.sh -arg1 -arg2

shasum=$(shasum -a 512 ${asset_name}.tar.gz | awk '{print$1}')
echo 'type: Asset
api_version: core/v2
metadata:
  name: '${asset_name}'
  namespace: ${namespace}
spec:
  sha512: '${shasum}'
  url: https://url.for.asset/upload/'${asset_name}'.tar.gz' > resource_type/resource_name.yaml

sensuctl create -f resource_type/resource_name.yaml

you could go a step further and have all the resources in one script and you could specify the type to get the proper definition.