Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: State Management for Entities #27

Open
nheimlich opened this issue May 21, 2021 · 1 comment
Open

Enhancement: State Management for Entities #27

nheimlich opened this issue May 21, 2021 · 1 comment
Assignees

Comments

@nheimlich
Copy link

nheimlich commented May 21, 2021

Hi, I am currently using the entity API to mass update entity labels and subscriptions. I believe it would be highly beneficial to have entities state-managed integrated through sensu flow as well. I've attached code snippets of my basic script to update such components. Currently, it requires the API_Key and namespace as inputs.

curl -X GET \ https://demo.sensu.io:8080/api/core/v2/namespaces/$namespace/entities \ -H "Authorization: Key $API_KEY" | jq -r '.[].metadata.name' >> test.txt

input="test.txt" while IFS= read -r host; do curl -X PATCH \ -H "Authorization: Key $API_KEY" \ -H 'Content-Type: application/merge-patch+json' \ -d '{ "metadata": { "labels": { "proc_name": "cron" } } }' \ https://demo.sensu.io:8080/api/core/v2/namespaces/$namespace/entities/$host

input="test.txt" while IFS= read -r host; do curl -X PATCH \ -H "Authorization: Key $API_KEY" \ -H 'Content-Type: application/merge-patch+json' \ -d '{ "subscriptions": ["system/linux/","ping"] }' \ https://demo.sensu.io:8080/api/core/v2/namespaces/$namespace/entities/$host done <"$input"
rm test.txt

A way to support this would to generate a file within cluster that has all of the entities states. Attached is a purposed image of what this file would look like. This is a file that ansible would use to ensure hosts can use custom fields.

image

@nheimlich nheimlich changed the title State Management for Entities Enhancement: State Management for Entities May 21, 2021
@calebhailey calebhailey self-assigned this Jun 8, 2021
@jspaleta
Copy link
Contributor

jspaleta commented Jun 2, 2022

Hmm this is a little different functionality than originally envisioned. This introduces a yaml file that isn't a sensu resource.

I get why this is desired, to coerse entities into compliance, but this might be better a distinct script separate from sensu-flow that can be run a separate ci or cron job on a different cadence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants