-
Notifications
You must be signed in to change notification settings - Fork 166
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
filter sudoers file by host specifics #26
Comments
To filter by host the pillar structure for this formula needs to change. My private template for
This forces comments on the operator but I found no other way to introduce a key to form a dictionary with the priv specs as values. Of course, aliases are accepted for users, hosts, etc but their actual existence in pillar isn't checked ;) |
Filtering for the current host would be easy in my pillar format for plain hostnames. But I think filtering for host aliases containing the current host will be difficult or at least complex in any format. |
Thanks @0xf10e for the reply. I like the privileges pillar idea. but can you elaborate more on how incorporate this pillar format with this sudoers formula? |
@aabognah I'll see if I can throw together something using my format and filtering for hosts. |
I came up with a format that I think works for me. First I changed the pillars structure as follows:
and in the sudoers file template I change:
To this:
There are a couple checks in the template to make sure the a line is not added twice and to propurly join lists in the suborders format (using ','.join()). I've also made similar changes in the aliases section to only add aliases that are referenced in the privileges section.
All of this allows having one big sudoers template with all aliases and specification for all hosts but only the bits relevant to the host will be part of its sudoers file. Thanks |
The sudoers file currently includes all pillar data. this means that a host sudoers file will include all the aliases for example even if it does not use them. It would be nice to have the sudoers file tailored to the host to isolate issues. for instance, now if I go in and add a new hosts aliase and make a mistake in the pillar so that salt cant catch it because its yaml correct but sudoers file wont parse it (it happened believe me) this will break all sudoers files in all hosts. but if the aliases are added only in the files that use them this will limit the impact of a mistake like this.
How would one go about doing so? is it possible to have multiple sudoers pillar files and filter what goes into the sudoers file based on host its going on?
The text was updated successfully, but these errors were encountered: