Skip to content

Commit

Permalink
[sudo]: basic sudoers cookbook added
Browse files Browse the repository at this point in the history
  • Loading branch information
mdxp committed Dec 14, 2011
1 parent 957d520 commit cd9e9ae
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sudo/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
maintainer "Promet Solutions"
maintainer_email "[email protected]"
license "Apache 2.0"
description "Configures sudoers"
version "1.0.0"

12 changes: 12 additions & 0 deletions sudo/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package "sudo" do
action :upgrade
end

template "/etc/sudoers" do
source "sudoers.erb"
mode 0440
owner "root"
group "root"
sudogroups =
variables(:sudoers_groups => node[:active_sudo_groups], :sudoers_users => node[:active_sudo_users], :sudoers_cmd => node[:active_sudo_cmd])
end
34 changes: 34 additions & 0 deletions sudo/templates/default/sudoers.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# /etc/sudoers
#
# Generated by Chef for <%= @node[:fqdn] %>
#

Defaults env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

<% if @sudoers_groups && !@sudoers_groups.empty? %>
<% @sudoers_groups.each do |group| -%>
# Members of the group '<%= group %>' may gain root privileges
%<%= group %> ALL=(ALL) NOPASSWD:ALL
<% end -%>
<% end %>

# User privilege specification
root ALL=(ALL) ALL
<% if @sudoers_users && !@sudoers_users.empty? %>
<% @sudoers_users.each do |user| -%>
<%= user %> ALL=(ALL) NOPASSWD:ALL
<% end -%>
<% end %>

<% if @sudoers_cmd && !@sudoers_cmd.empty? %>
<% @sudoers_cmd.each do |cmd| -%>
<%= cmd[:user] %> ALL = <%= cmd[:command] || "ALL" %>
<% end -%>
<% end %>

0 comments on commit cd9e9ae

Please sign in to comment.