-
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
Feature Request: Template variable to explain source of a file #37068
Comments
For a better following up I will add my comment in here. First as a temporary solution you can create your own Pillar for example lets call it {% set managed_text = 'Salt managed: File modified on ' + salt.cmd.run('date "+DATE: %Y-%m-%d TIME: %H:%M:%S"') %}
salt_managed: {{ managed_text | yaml_dquote }} Then on the minion you will get this result: $ salt-call pillar.get salt_managed
local:
Salt managed: File modified on DATE: 2016-10-18 TIME: 11:12:40
And you can use this by adding it on the top of your config files for example like this {{ pillar.get('salt_managed') }} The main problem with this solution that i cannot get the user who executed a state from the event bus, if there is a way to achieve that it would be very helpful then. what do you think ? |
@mostafahussein implementing this via pillar looks good. I don't understand why you want to get the user who executed a state. At least in my environment it will always be |
I think this is a great idea. I'll approve as a feature request thanks |
@guettli my environment has multiple user and we are using ssh keys. so i will be able to know who have updated the file and when. Should I add the above implementation as answer to your question ? |
@Ch3LL Is there a way to access the event bus during state execution ? or even by creating a custom module ? Update: 1- Can we get the file reference during execution ? (I can see it in state.show.sls results but i wish if it could be called inside the managed file itself) |
@mostafahussein yes, please answer my StackO question with your sample implementation. It's a good starting point. I hope there is a way to figure out which file gets processed at the moment. |
@guettli I have added it to your question. and if there is any other solutions then i will keep you updated. |
@mostafahussein, to answer your first question, maybe try https://github.com/saltstack/salt/blob/develop/salt/utils/templates.py#L141-L145 |
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 would like to see such a feature too. @mostafahussein 's approach with the pillars is nice but has the downside that it always update the templates, even if nothing changes inside. That's not exactly what I would want in general. |
Indeed, it totally is not what most want. |
Description of Issue/Question
I want to know where config files on a minion come from.
Example
I am lazy, and don't want to maintain above information myself.
There is a cool feature for ansible. The template system provides a variable
{{ ansible_managed }}
This gets expanded to the source of the file and a time stamp.
See: http://docs.ansible.com/ansible/intro_configuration.html#ansible-managed
It would be great to have such a feature in salt, too.
Related StackO question: http://stackoverflow.com/questions/39747351/saltstack-reverse-engineering-where-a-file-comes-from
What do you think?
The text was updated successfully, but these errors were encountered: