Skip to content

Commit

Permalink
Latest brew install needs extended sudo rights
Browse files Browse the repository at this point in the history
Signed-off-by: Antek S. Baranski <[email protected]>
  • Loading branch information
Sauraus committed Dec 9, 2016
1 parent daf2a3a commit 94e9d36
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
4 changes: 4 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@
default['homebrew']['taps'] = []
default['homebrew']['installer']['url'] = 'https://raw.githubusercontent.com/Homebrew/install/master/install'
default['homebrew']['installer']['checksum'] = nil
default['homebrew']['sudo']['commands'] =
%w( /bin/chmod /usr/sbin/chown /bin/mkdir /usr/bin/chgrp /usr/bin/touch
/usr/sbin/softwareupdate /bin/rm
)
31 changes: 26 additions & 5 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,32 @@
not_if { ::File.exist? '/usr/local/bin/brew' }
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'],
:commands => node['homebrew']['sudo']['commands'] }
}
)
action :create
mode '00644'
user 'root'
group 'wheel'
not_if { (::File.exist? '/usr/local/bin/brew') || node['homebrew']['sudo']['commands'].empty? }
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
3 changes: 3 additions & 0 deletions templates/default/homebrew_sudo.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% @commands.each do |command| %>
<%= @user %> <%= @hostname %>=(root) NOPASSWD: <%= command %>
<% end %>

0 comments on commit 94e9d36

Please sign in to comment.