Skip to content

Commit

Permalink
Latest brew install needs extended sudo rights
Browse files Browse the repository at this point in the history
This fixes: sous-chefs#105
  • Loading branch information
Sauraus committed Oct 5, 2016
1 parent 61274fd commit 97b8f0e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
28 changes: 23 additions & 5 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,29 @@
mode 00755
end

execute 'install homebrew' do
command homebrew_go
environment lazy { { 'HOME' => ::Dir.home(homebrew_owner), 'USER' => homebrew_owner } }
user homebrew_owner
not_if { ::File.exist? '/usr/local/bin/brew' }
begin
template '/etc/sudoers.d/homebrew_sudo' do
source 'homebrew_sudo.erb'
variables (
lazy { { :user => homebrew_owner, :hostname => node['hostname'] } }
)
action :create
mode '00644'
user 'root'
group 'wheel'
not_if { ::File.exist? '/usr/local/bin/brew' }
end

execute 'install homebrew' do
command "#{homebrew_go} < /dev/null"
environment lazy { { 'HOME' => ::Dir.home(homebrew_owner), 'USER' => homebrew_owner } }
user homebrew_owner
not_if { ::File.exist? '/usr/local/bin/brew' }
end
ensure
file '/etc/sudoers.d/homebrew_go' do
action :delete
end
end

if node['homebrew']['auto-update']
Expand Down
7 changes: 7 additions & 0 deletions templates/default/homebrew_sudo.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= @user %> <%= @hostname %>=(root) NOPASSWD: /bin/chmod
<%= @user %> <%= @hostname %>=(root) NOPASSWD: /usr/sbin/chown
<%= @user %> <%= @hostname %>=(root) NOPASSWD: /bin/mkdir
<%= @user %> <%= @hostname %>=(root) NOPASSWD: /usr/bin/chgrp
<%= @user %> <%= @hostname %>=(root) NOPASSWD: /usr/bin/touch
<%= @user %> <%= @hostname %>=(root) NOPASSWD: /usr/sbin/softwareupdate
<%= @user %> <%= @hostname %>=(root) NOPASSWD: /bin/rm

0 comments on commit 97b8f0e

Please sign in to comment.