-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Added pillar:// scheme to file.managed. #6508
Added pillar:// scheme to file.managed. #6508
Conversation
This allows pillar data to be placed into a file without having to worry about indentation in a sls file.
I would be hesitant to add this just to the file state, if we had something like this then it should be implemented at the level of the fileclient. Otherwise, the other states that use file URIs won't have support for it, which is unintuitive and would confuse users. I'm interested to hear what the other core devs think, however. |
That's a great point. I looked through the code and wasn't quite sure how to fit it into fileclient. Any pointers on where it should go? |
Not sure, I've done some work in the fileclient before but I'd have to take some time to see how it would fit in. Overall, I love the idea, because the current way of accomplishing something like this is to first create a jinja template file containing a reference to the pillar that you want to use, and then make a file.managed state like the following:
This is quite hacky and means you need to have a different template file for each pillar that you wish to reference in this way. So I love the idea of creating an interface to pillar. |
Wow @rca, this is simple! I don't think that this will be able to work in other states quite the same way since only file.managed supports contents. Also I don't think that this can work in the fileclient, again it does not translate cleanly. |
This has been a highly requested feature. I agree that it's mostly useful
|
Per discussion in issue saltstack#6508 applying a `pillar://` scheme to the `source` parameter will be confusing because there is no parity with other locations that use `source` and the most useful location for this is the `file.managed` state. In order to alleviate the problem, apply the logic to the `contents` parameter, which is only supported in `file.managed`.
How about moving |
Example usage now is:
|
How about we add a pillar argument to file.managed? So that we don't have to confuse a new URL? So it would be like this:
|
Instead of calling it just |
Yes. I was thinking the same |
This builds off of pull req saltstack#6508, but discards the new URI scheme for a dedicated argument to get the file contents from pillar.
@rca I just submitted a pull request to your fork. If this works for you, feel free to merge it and this pull should be ready to merge. |
…heme Convert pillar:// scheme to contents_pillar variable
@terminalmage: merged and added some tests. |
Sweet! It looks good, but I'd like to test it on Windows as well before it is merged. I'll test it on Monday morning. |
This works on Windows, and can now be merged into develop. |
Added pillar:// scheme to file.managed.
Thanks @rca for the suggestion, and double thanks for the test! |
No problem, glad I can help! |
It's very difficult to use the
contents
option infile.managed
with pillar data and I came up with a quick way to get this functionality intofile.managed
by passing in asource
with thepillar://
scheme followed by a path usable bypillar.get
. This works amazingly well and looks to me like a natural fit to the wayfile.managed
operates. For example:Please share your thoughts and if there is a better place to check for the pillar scheme. The current implementation is a bit hacked in and needs tests.
Thanks.