Skip to content

Commit

Permalink
Bailout when no web-password was given, while trying to configure a g…
Browse files Browse the repository at this point in the history
…anglia server and bypass invalid web-user values.

cr https://cr.amazon.com/r/1628766/
  • Loading branch information
Christian Requena committed Aug 23, 2013
1 parent 1d46595 commit 1fc4095
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions opsworks_ganglia/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
default[:ganglia][:web][:svn] = 'no'
default[:ganglia][:web][:url] = '/ganglia'
default[:ganglia][:web][:welcome_page] = 'ganglia_welcome.html'
default[:ganglia][:web][:user] = 'opsworks'
default[:ganglia][:web][:password] = SecureRandom.base64[0...20]

default[:ganglia][:web][:user] = (node['ganglia']['web']['user'].blank? rescue true) ? 'opsworks' : node['ganglia']['web']['user']

default[:ganglia][:web][:destdir] = case node[:platform_family]
when "rhel"
"/usr/share/ganglia"
Expand Down
5 changes: 5 additions & 0 deletions opsworks_ganglia/recipes/configure-server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
end
end

if (node['ganglia']['web']['password'].blank? rescue true)
Chef::Log.error "Bailing out while configuring Ganglia Server. Password for ganglia webfrontend was not defined. Please set a non-empty password and try again."
exit 1
end

execute 'Update htpasswd secret' do
command "htpasswd -b -c /etc/ganglia-webfrontend/htaccess #{node[:ganglia][:web][:user]} #{node[:ganglia][:web][:password]}"
end
Expand Down

0 comments on commit 1fc4095

Please sign in to comment.