Skip to content

Commit 50fa383

Browse files
Extract separate recipe for different install
1 parent abf0243 commit 50fa383

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

recipes/default.rb

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
# See the License for the specific language governing permissions and
1717
# limitations under the License.
1818
#
19-
20-
include_recipe "git"
21-
2219
unless Chef::Config[:solo]
2320
es_server_results = search(:node, "roles:#{node['grafana']['es_role']} AND chef_environment:#{node.chef_environment}")
2421
unless es_server_results.empty?
@@ -48,35 +45,9 @@
4845

4946
case node['grafana']['install_type']
5047
when "git"
51-
git "#{node['grafana']['install_dir']}/#{node['grafana']['git']['branch']}" do
52-
repository node['grafana']['git']['url']
53-
reference node['grafana']['git']['branch']
54-
case node['grafana']['git']['type']
55-
when "checkout"
56-
action :checkout
57-
when "sync"
58-
action :sync
59-
end
60-
user grafana_user
61-
end
62-
link "#{node['grafana']['install_dir']}/current" do
63-
to "#{node['grafana']['install_dir']}/#{node['grafana']['git']['branch']}"
64-
end
65-
node.set['grafana']['web_dir'] = "#{node['grafana']['install_dir']}/current/src"
48+
include_recipe 'grafana::install_git'
6649
when "file"
67-
case node['grafana']['file']['type']
68-
when "zip"
69-
include_recipe 'ark::default'
70-
ark 'grafana' do
71-
url node['grafana']['file']['url']
72-
path node['grafana']['install_path']
73-
checksum node['grafana']['file']['checksum']
74-
owner grafana_user
75-
strip_leading_dir false
76-
action :put
77-
end
78-
node.set['grafana']['web_dir'] = node['grafana']['install_dir']
79-
end
50+
include_recipe 'grafana::install_file'
8051
end
8152

8253
template "#{node['grafana']['web_dir']}/config.js" do

recipes/install_file.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
case node['grafana']['file']['type']
2+
when "zip"
3+
include_recipe 'ark::default'
4+
ark 'grafana' do
5+
url node['grafana']['file']['url']
6+
path node['grafana']['install_path']
7+
checksum node['grafana']['file']['checksum']
8+
owner grafana_user
9+
strip_leading_dir false
10+
action :put
11+
end
12+
node.set['grafana']['web_dir'] = node['grafana']['install_dir']
13+
end

recipes/install_git.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
include_recipe "git"
3+
4+
git "#{node['grafana']['install_dir']}/#{node['grafana']['git']['branch']}" do
5+
repository node['grafana']['git']['url']
6+
reference node['grafana']['git']['branch']
7+
case node['grafana']['git']['type']
8+
when "checkout"
9+
action :checkout
10+
when "sync"
11+
action :sync
12+
end
13+
user grafana_user
14+
end
15+
16+
link "#{node['grafana']['install_dir']}/current" do
17+
to "#{node['grafana']['install_dir']}/#{node['grafana']['git']['branch']}"
18+
end
19+
20+
node.set['grafana']['web_dir'] = "#{node['grafana']['install_dir']}/current/src"

0 commit comments

Comments
 (0)