arnoudj / puppet-sudo

Puppet module to manage sudoers.
8 stars 23 forks source link

Defaults do not work with groups #27

Open jonathandelanders opened 9 years ago

jonathandelanders commented 9 years ago

First off, Fantastic module..

When I attempt to deploy defaults with a group ( specifically !requiretty ) the settings do not take. I patched the module to work on my puppet master and the code below to allow using defaults with group.

diff --git a/modules/sudo/templates/sudoers.erb b/modules/sudo/templates/sudoers.erb
index e852b31..9902fda 100644
--- a/modules/sudo/templates/sudoers.erb
+++ b/modules/sudo/templates/sudoers.erb
@@ -13,7 +13,11 @@ Cmnd_Alias  <%= @sane_name.upcase %>_CMNDS = <%= @cmnds.class == Array ? @cmnds.

 <% if not @defaults.empty? then -%>

+<% if @users then -%>
 Defaults:<%= @sane_name.upcase %>_USERS <%= @defaults.class == Array ? @defaults.join(", ") : @defaults %>
+<% else -%>
+Defaults:%<%= @group %> <%= @defaults.class == Array ? @defaults.join(", ") : @defaults %>
+<% end -%>
 <% end -%>

 <% if @users then -%>
gotyaoi commented 9 years ago

While it doesn't look as if this issue is accurate to the file as it currently exists, I think this is something that bears discussion. There are some defaults that seem like they should be applied per user (requiretty, in my case), and some that seem like the might be better per command (log_output, for example). Perhaps it should be a further setting that determines if the default should be applied to the user/group, as in @jonathandelanders example, or to the command, as it currently is?

Ramorous commented 8 years ago

I forked the template to provide a proper groups fix.