Skip to content

Commit

Permalink
Extract separate recipe for different install
Browse files Browse the repository at this point in the history
  • Loading branch information
kamaradclimber committed Mar 24, 2014
1 parent abf0243 commit 50fa383
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
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
13 changes: 13 additions & 0 deletions recipes/install_file.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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

This comment has been minimized.

Copy link
@klamontagne

klamontagne Mar 31, 2014

grafana_user is not defined here

This comment has been minimized.

Copy link
@kamaradclimber

kamaradclimber Apr 1, 2014

Author Contributor

18286e8 fixes the issue indeed

strip_leading_dir false
action :put
end
node.set['grafana']['web_dir'] = node['grafana']['install_dir']
end
20 changes: 20 additions & 0 deletions recipes/install_git.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

include_recipe "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

This comment has been minimized.

Copy link
@klamontagne

klamontagne Mar 31, 2014

grafana_user is not defined here

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"

0 comments on commit 50fa383

Please sign in to comment.