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
suggestion: logging state #1904
Comments
Are you familiar with the failhard option? This was made for this case, as for adding in log data I think that we could just make a failhard state that accepted a number of things to check on and to fail hard and early, no need to mess around in Jinja :) |
I had not seen the failhard option, thank you for the heads up. I don't think it quite meets my needs, though. My use case was as more of a sanity check in an SLS. I don't want a state to even attempt to resolve at all if the grains and pillar it depends on are out of whack. A failhard state might be the right solution, depending. I'd like to give it an implicit ordering preference. Such that any failhard states are resolved first before attempting the rest of the tree. I agree that jinja isn't the place for this, I just wanted to provide some of my background thinking. |
Are you familiar with finite ordering? We could write a state that could do this directly as well, one that would add failhard internally and set a default order of 1 |
Wow, I was not familiar with the ordering option. I thought I had a pretty good grasp on the documentation, but clearly I do not. That combination sounds perfect. |
I want to make the docs all get ordered out in a manual style setup, but time is not on my side :) |
The combination of ordering and failhard didn't really end up solving my issue. I'd like to revisit the option of a 'failure' state. I saw some discussion about exception handling for states recently. I think that an exception would be a good vector for transmitting the failure back up to the calling instance. I'd be happy to provide a proof-of-concept if needed. |
Thant interesting, I will reopen this then |
So, as I see it, a workaround can look a bit like this...
It seems to me that a new/custom state module could handle this (common?) case a bit better. Something like...
Such a state could yield intelligent output on what particular conditions were checked / failed. For example, the state module output could contain "Assertion grains['os'] == 'CentOS' failed." One issue I see with pushing the check deeper into the state is that it wouldn't support creation of more detailed checks. For example, creating a check that the major version of grains['osrelease'] is greater than 5 (grains['osrelease']. Thoughts? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. |
I come to Salt after doing a lot of research and experimentation with Puppet. One of the patterns I would use for Puppet was the platform gatekeeping approach:
That will abort compilation of the manifest immediately and provide the info in the returned report. It allows me to make manifests that aren't tested on all platforms and be assured that one of my fellow administrators won't accidentally apply untested code.
It's a bit of a trivial example, as it should be pretty easy to document for one's team which states would work on which platforms. And you would hope that whomever you allow to work on your configuration infrastructure wouldn't be a buffoon ;) - I liked having the mechanism as a parachute for both basic and advanced cases.
I'd like to get some of that functionality in Salt as well. Say through the use of a
log
state.Or maybe for testing:
I don't know. My
log.info
example seems a little contrived. Butlog.abort
is still pretty valuable.I considered the feasibility of putting something like this in the jinja context, as the only variability in your states comes from templating. But that means it wouldn't follow the rest of Salt's ideology for multiple state renderers.
The text was updated successfully, but these errors were encountered: