Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract install recipes #2

Merged
merged 2 commits into from
Mar 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
default['grafana']['file']['url'] = "https://github.com/torkelo/grafana/releases/download/v1.5.1/grafana-1.5.1.zip"
default['grafana']['file']['checksum'] = "0497f22cf4d3be819997f527a4ec55897c1941ebb035bf943e1b98a4dc6fec27" # sha256 ( shasum -a 256 FILENAME )
default['grafana']['webserver'] = "nginx"
case node['grafana']['install_type']
when 'git'
default['grafana']['web_dir'] = "#{node['grafana']['install_dir']}/current/src"
when 'file'
default['grafana']['web_dir'] = node['grafana']['install_dir']
end
default['grafana']['install_path'] = "/opt"
default['grafana']['install_dir'] = "#{node['grafana']['install_path']}/grafana"
default['grafana']['es_server'] = "127.0.0.1"
Expand Down
33 changes: 2 additions & 31 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

include_recipe "git"

unless Chef::Config[:solo]
es_server_results = search(:node, "roles:#{node['grafana']['es_role']} AND chef_environment:#{node.chef_environment}")
unless es_server_results.empty?
Expand Down Expand Up @@ -48,35 +45,9 @@

case node['grafana']['install_type']
when "git"
git "#{node['grafana']['install_dir']}/#{node['grafana']['git']['branch']}" do
repository node['grafana']['git']['url']
reference node['grafana']['git']['branch']
case node['grafana']['git']['type']
when "checkout"
action :checkout
when "sync"
action :sync
end
user grafana_user
end
link "#{node['grafana']['install_dir']}/current" do
to "#{node['grafana']['install_dir']}/#{node['grafana']['git']['branch']}"
end
node.set['grafana']['web_dir'] = "#{node['grafana']['install_dir']}/current/src"
include_recipe 'grafana::install_git'
when "file"
case node['grafana']['file']['type']
when "zip"
include_recipe 'ark::default'
ark 'grafana' do
url node['grafana']['file']['url']
path node['grafana']['install_path']
checksum node['grafana']['file']['checksum']
owner grafana_user
strip_leading_dir false
action :put
end
node.set['grafana']['web_dir'] = node['grafana']['install_dir']
end
include_recipe 'grafana::install_file'
end

template "#{node['grafana']['web_dir']}/config.js" do
Expand Down
12 changes: 12 additions & 0 deletions recipes/install_file.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
case node['grafana']['file']['type']
when "zip"
include_recipe 'ark::default'
ark 'grafana' do
url node['grafana']['file']['url']
path node['grafana']['install_path']
checksum node['grafana']['file']['checksum']
owner grafana_user
strip_leading_dir false
action :put
end
end
13 changes: 13 additions & 0 deletions recipes/install_git.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

include_recipe "git"

git "#{node['grafana']['install_dir']}/#{node['grafana']['git']['branch']}" do
repository node['grafana']['git']['url']
reference node['grafana']['git']['branch']
action node['grafana']['git']['type'].to_s
user grafana_user
end

link "#{node['grafana']['install_dir']}/current" do
to "#{node['grafana']['install_dir']}/#{node['grafana']['git']['branch']}"
end