-
Notifications
You must be signed in to change notification settings - Fork 14
Can't Add Command Line Arguments Once Check is Configured #45
Comments
You may want to try files (instead of ad-hoc commands). I'm sure what I've done below is not best-practice, but until I see otherwise I will use it. I've added to this playbook so that ansible creates
Then add or update the check with sensuctl. I created a shell script for this, that may or may not be necessary (wildcards could be supported) |
I see what you're getting at - that's an approach I've used elsewhere for something-or-other. Depending on your shell script, you may have the same problem - that is, you can't change a check config. I tried a bit on the command line:
...says "OK" and indeed the check is created. However, running it again with a modification:
...fails with:
...and a shell exit code of 1. Thus, you could look for non-zero return code and then delete the check and re-create it. So long as you only delete-and-recreate when Ansible tells you to do so (ie. when the file changes), then you would work around the problem I've reported. Also, since the underlying |
Try the yaml file - it works for me (creates and updates) |
Hey @coofercat! Thanks for the issue! I think with the way I have currently created that initial attempt at a The logic overall isn't too crazy, might make sense to do that here: https://github.com/jaredledvina/sensu-go-ansible/blob/master/library/sensu_go_check.py#L147-L159 Tangentially related, I'm not totally sure about the use of Anyway, thanks again, lemme know what you think. EDIT: |
3 months later, I found free time! Opened #93 which migrates the existing module off of using If folks want to test it, go for it and let me know if it works! It's very much a v0 but, I think the user experience is waaay nicer. |
First up, just to say, the sensu_go_plugin library looks great - it's helped me get some monitoring on some stuff that's really in need of it ;-)
Onto my observation: Once a check has been configured, it can't be changed without removing it and re-inserting it. As a test case, doing this with ad-hoc:
This returns the check configuration, which looks correct:
All fine so far. However, an attempt to update it with:
Returns:
If the above check is removed with a
state=absent
and then re-added using the same command as above then it is correctly updated in both the console output and in the Sensu web UI.I had a bit of a look at the library code - I'm not entirely sure how to approach any possible solution. Since a 'list' operation returns everything the server knows, I guess it could just be a matter of stepping through the list output looking for the current 'name'. If found, either update it (if the API allows) or remove and re-add if not...? It could make the whole thing pretty slow, although each 'add' would update the list. Another option would be to try to add it anyway, and then get the list if you get the 'Check already defined in Sensu' message. Lastly, maybe it's an upstream change to the Sensu API to do the update if we're asking for a slightly different check?
The text was updated successfully, but these errors were encountered: