Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #16 from hw-cookbooks/develop

Develop to Master
  • Loading branch information...
commit 43aadd76db5b4960a697a3f229aed12723dacd04 2 parents ac0c84b + a670c63
Sean Escriva authored February 02, 2013
3  .gitignore
@@ -2,3 +2,6 @@
2 2
 .cache
3 3
 .kitchen
4 4
 bin
  5
+.jamie/
  6
+.jamie.local.yml
  7
+.vagrant
22  .jamie.yml
... ...
@@ -0,0 +1,22 @@
  1
+---
  2
+driver_plugin: vagrant
  3
+platforms:
  4
+- name: ubuntu-12.04
  5
+  driver_config:
  6
+    box: opscode-ubuntu-12.04
  7
+    box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_chef-10.18.2.box
  8
+  run_list:
  9
+  - recipe[apt]
  10
+suites:
  11
+- name: carbon
  12
+  run_list:
  13
+  - recipe[minitest-handler]
  14
+  - recipe[graphite_test::carbon]
  15
+- name: carbon_runit
  16
+  run_list:
  17
+  - recipe[minitest-handler]
  18
+  - recipe[graphite_test::carbon_runit]
  19
+- name: carbon_runit_twistd
  20
+  run_list:
  21
+  - recipe[minitest-handler]
  22
+  - recipe[graphite_test::carbon_runit_twistd]
3  Gemfile
... ...
@@ -1,3 +1,4 @@
1 1
 source :rubygems
2 2
 
3  
-gem 'test-kitchen'
  3
+gem 'jamie'
  4
+gem 'jamie-vagrant', :group => :integration
113  Gemfile.lock
@@ -2,102 +2,41 @@ GEM
2 2
   remote: http://rubygems.org/
3 3
   specs:
4 4
     archive-tar-minitar (0.5.2)
5  
-    bunny (0.7.9)
6  
-    chef (10.14.4)
7  
-      bunny (>= 0.6.0, < 0.8.0)
8  
-      erubis
9  
-      highline (>= 1.6.9)
10  
-      json (>= 1.4.4, <= 1.6.1)
11  
-      mixlib-authentication (>= 1.3.0)
12  
-      mixlib-cli (>= 1.1.0)
13  
-      mixlib-config (>= 1.1.2)
14  
-      mixlib-log (>= 1.3.0)
15  
-      mixlib-shellout
16  
-      moneta
17  
-      net-ssh (~> 2.2.2)
18  
-      net-ssh-multi (~> 1.1.0)
19  
-      ohai (>= 0.6.0)
20  
-      rest-client (>= 1.0.4, < 1.7.0)
21  
-      treetop (~> 1.4.9)
22  
-      uuidtools
23  
-      yajl-ruby (~> 1.1)
24  
-    childprocess (0.3.5)
  5
+    celluloid (0.12.4)
  6
+      facter (>= 1.6.12)
  7
+      timers (>= 1.0.0)
  8
+    childprocess (0.3.7)
25 9
       ffi (~> 1.0, >= 1.0.6)
26 10
     coderay (1.0.8)
27 11
     erubis (2.7.0)
28  
-    ffi (1.1.5)
29  
-    foodcritic (1.6.1)
30  
-      erubis
31  
-      gherkin (~> 2.11.1)
32  
-      gist (~> 3.1.0)
33  
-      nokogiri (= 1.5.0)
34  
-      pry (~> 0.9.8.4)
35  
-      rak (~> 1.4)
36  
-      treetop (~> 1.4.10)
37  
-      yajl-ruby (~> 1.1.0)
38  
-    gherkin (2.11.2)
39  
-      json (>= 1.4.6)
40  
-    gist (3.1.0)
41  
-    hashr (0.0.22)
42  
-    highline (1.6.15)
  12
+    facter (1.6.17)
  13
+    ffi (1.3.1)
43 14
     i18n (0.6.1)
44  
-    ipaddress (0.8.0)
  15
+    jamie (0.1.0.beta4)
  16
+      celluloid
  17
+      mixlib-shellout
  18
+      net-scp
  19
+      net-ssh
  20
+      pry
  21
+      thor
  22
+    jamie-vagrant (0.5.2)
  23
+      jamie (~> 0.1.0.beta1)
  24
+      vagrant (~> 1.0.5)
45 25
     json (1.5.4)
46  
-    librarian (0.0.24)
47  
-      archive-tar-minitar (>= 0.5.2)
48  
-      chef (>= 0.10)
49  
-      highline
50  
-      thor (~> 0.15)
51 26
     log4r (1.1.10)
52  
-    method_source (0.7.1)
53  
-    mime-types (1.19)
54  
-    mixlib-authentication (1.3.0)
55  
-      mixlib-log
56  
-    mixlib-cli (1.2.2)
57  
-    mixlib-config (1.1.2)
58  
-    mixlib-log (1.4.1)
  27
+    method_source (0.8.1)
59 28
     mixlib-shellout (1.1.0)
60  
-    moneta (0.6.0)
61 29
     net-scp (1.0.4)
62 30
       net-ssh (>= 1.99.1)
63 31
     net-ssh (2.2.2)
64  
-    net-ssh-gateway (1.1.0)
65  
-      net-ssh (>= 1.99.1)
66  
-    net-ssh-multi (1.1)
67  
-      net-ssh (>= 2.1.4)
68  
-      net-ssh-gateway (>= 0.99.0)
69  
-    nokogiri (1.5.0)
70  
-    ohai (6.14.0)
71  
-      ipaddress
72  
-      mixlib-cli
73  
-      mixlib-config
74  
-      mixlib-log
75  
-      systemu
76  
-      yajl-ruby
77  
-    polyglot (0.3.3)
78  
-    pry (0.9.8.4)
  32
+    pry (0.9.11.4)
79 33
       coderay (~> 1.0.5)
80  
-      method_source (~> 0.7.1)
81  
-      slop (>= 2.4.4, < 3)
82  
-    rak (1.4)
83  
-    rest-client (1.6.7)
84  
-      mime-types (>= 1.16)
85  
-    slop (2.4.4)
86  
-    systemu (2.5.2)
87  
-    test-kitchen (0.6.0)
88  
-      foodcritic (~> 1.4)
89  
-      hashr (~> 0.0.20)
90  
-      highline (>= 1.6.9)
91  
-      librarian (~> 0.0.20)
92  
-      mixlib-cli (~> 1.2.2)
93  
-      vagrant (~> 1.0.2)
94  
-      yajl-ruby (~> 1.1.0)
95  
-    thor (0.16.0)
96  
-    treetop (1.4.10)
97  
-      polyglot
98  
-      polyglot (>= 0.3.1)
99  
-    uuidtools (2.1.3)
100  
-    vagrant (1.0.5)
  34
+      method_source (~> 0.8)
  35
+      slop (~> 3.4)
  36
+    slop (3.4.3)
  37
+    thor (0.17.0)
  38
+    timers (1.1.0)
  39
+    vagrant (1.0.6)
101 40
       archive-tar-minitar (= 0.5.2)
102 41
       childprocess (~> 0.3.1)
103 42
       erubis (~> 2.7.0)
@@ -106,10 +45,10 @@ GEM
106 45
       log4r (~> 1.1.9)
107 46
       net-scp (~> 1.0.4)
108 47
       net-ssh (~> 2.2.2)
109  
-    yajl-ruby (1.1.0)
110 48
 
111 49
 PLATFORMS
112 50
   ruby
113 51
 
114 52
 DEPENDENCIES
115  
-  test-kitchen
  53
+  jamie
  54
+  jamie-vagrant
50  README.md
Source Rendered
@@ -6,13 +6,49 @@ Installs and configures Graphite http://graphite.wikidot.com/
6 6
 Requirements
7 7
 ============
8 8
 
9  
-* Ubuntu 10.04 (Lucid) - with default settings
10  
-* Ubuntu 11.10 (Oneiric) - change node[:graphite][:python_version] to "2.7"
  9
+* Ubuntu 10.04 / Ubuntu 12.04
11 10
 
12 11
 Attributes
13 12
 ==========
14 13
 
15  
-* `node[:graphite][:password]` sets the default password for graphite "root" user.
  14
+The name of the encrypted data bag containing the default password for
  15
+the graphite "root" user.  If this attribute is set it will not use
  16
+`node[:graphite][:password]`.
  17
+
  18
+* `node['graphite']['encrypted_data_bag']['name']`
  19
+
  20
+
  21
+* `node['graphite']['version']` - version of graphite to install (defaults to 0.9.10)
  22
+* `node['graphite']['password']` - password for graphite root user(default to `change_me` and is only used if encrypted databag isn't)
  23
+* `node['graphite']['url']` - url of the graphite server (defaults to graphite)
  24
+* `node['graphite']['url_aliases']` - array of url aliases (defaults to nil)
  25
+* `node['graphite']['listen_port']` - port to listen on (defaults to 80)
  26
+* `node['graphite']['base_dir']` = "/opt/graphite"
  27
+* `node['graphite']['doc_root']` = "/opt/graphite/webapp"
  28
+* `node['graphite']['storage_dir']` = "/opt/graphite/storage"
  29
+* `node['graphite']['django_root']` = "@DJANGO_ROOT@" - configurable path to your django installation
  30
+
  31
+* `node['graphite']['whisper']['uri']` - download url for whisper
  32
+* `node['graphite']['whisper']['checksum']` - checksum of the whisper download
  33
+
  34
+* `node['graphite']['graphite_web']['uri']` - download url for the graphite web ui
  35
+* `node['graphite']['graphite_web']['checksum']` - checksum for the graphite web ui download
  36
+
  37
+* `node['graphite']['carbon']['uri']` - download url for carbon
  38
+* `node['graphite']['carbon']['checksum']` - checksum for the carbon download
  39
+* `node['graphite']['carbon']['line_receiver_interface']` - line interface IP (defaults to 0.0.0.0)
  40
+* `node['graphite']['carbon']['line_receiver_port']` - line interface port (defaults to 2003)
  41
+* `node['graphite']['carbon']['pickle_receiver_interface']` - pickle receiver IP (defaults to 0.0.0.0)
  42
+* `node['graphite']['carbon']['pickle_receiver_port']` - pickle receiver port (defaults to 2004)
  43
+* `node['graphite']['carbon']['cache_query_interface']` - cache query IP (defaults to 0.0.0.0)
  44
+* `node['graphite']['carbon']['cache_query_port']` - cache query port (defaults to 7002)
  45
+* `node['graphite']['carbon']['max_updates_per_second']` - max updates to carbon per second (defaults to 1000)
  46
+* `node['graphite']['carbon']['service_type']` - init service to use for carbon (defaults to runit)
  47
+* `node['graphite']['carbon']['log_whisper_updates']` - log updates to whisper (defaults to false)
  48
+
  49
+Set the timezone for the graphite web interface, defaults to America/Los_Angeles
  50
+
  51
+* `node[:graphite][:timezone]`
16 52
 
17 53
 Usage
18 54
 =====
@@ -22,11 +58,3 @@ Usage
22 58
 `recipe[graphite::ganglia]` integrates with Ganglia. You'll want at
23 59
 least one monitor node (i.e. recipe[ganglia]) node to be running
24 60
 to use it.
25  
-
26  
-Caveats
27  
-=======
28  
-
29  
-Ships with two default schemas, stats.* (for Etsy's statsd) and a
30  
-catchall that matches anything. The catchall retains minutely data for
31  
-13 months, as in the default config. stats retains data every 10 seconds
32  
-for 6 hours, every minute for a week, and every 10 minutes for 5 years.
5  Vagrantfile
... ...
@@ -0,0 +1,5 @@
  1
+require 'jamie/vagrant'
  2
+
  3
+Vagrant::Config.run do |config|
  4
+  Jamie::Vagrant.define_vms(config)
  5
+end
46  attributes/graphite.rb
... ...
@@ -1,23 +1,35 @@
1  
-default['graphite']['version'] = "0.9.9"
2  
-default['graphite']['python_version'] = "2.6"
3  
-
4  
-default['graphite']['carbon']['uri'] = "http://launchpadlibrarian.net/82112362/carbon-#{node['graphite']['version']}.tar.gz"
5  
-default['graphite']['carbon']['checksum'] = "b3d42e3b93c09"
6  
-
7  
-default['graphite']['whisper']['uri'] = "http://launchpadlibrarian.net/82112367/whisper-#{node['graphite']['version']}.tar.gz"
8  
-default['graphite']['whisper']['checksum'] = "66c05eafe8d86"
9  
-
10  
-default['graphite']['graphite_web']['uri'] = "http://launchpadlibrarian.net/82112308/graphite-web-#{node['graphite']['version']}.tar.gz"
11  
-default['graphite']['graphite_web']['checksum'] = "cc78bab7fb26b"
12  
-
13  
-default['graphite']['carbon']['line_receiver_interface'] =   "127.0.0.1"
14  
-default['graphite']['carbon']['pickle_receiver_interface'] = "127.0.0.1"
15  
-default['graphite']['carbon']['cache_query_interface'] =     "127.0.0.1"
16  
-default['graphite']['carbon']['service_type'] = "runit"
  1
+#
  2
+# Cookbook Name:: graphite
  3
+# Attributes:: graphite
  4
+#
17 5
 
  6
+default['graphite']['version'] = "0.9.10"
18 7
 default['graphite']['password'] = "change_me"
19 8
 default['graphite']['url'] = "graphite"
20 9
 default['graphite']['url_aliases'] = []
21  
-default['graphite']['listen_port'] = "80"
  10
+default['graphite']['listen_port'] = 80
22 11
 default['graphite']['base_dir'] = "/opt/graphite"
23 12
 default['graphite']['doc_root'] = "/opt/graphite/webapp"
  13
+default['graphite']['storage_dir'] = "/opt/graphite/storage"
  14
+default['graphite']['timezone'] = "America/Los_Angeles"
  15
+default['graphite']['django_root'] = "@DJANGO_ROOT@"
  16
+
  17
+default['graphite']['whisper']['uri'] = "https://launchpad.net/graphite/0.9/#{node['graphite']['version']}/+download/whisper-#{node['graphite']['version']}.tar.gz"
  18
+default['graphite']['whisper']['checksum'] = "36b5fa917526224678da0a530a6f276d00074f0aa98acd6e2412c79521f9c4ff"
  19
+
  20
+default['graphite']['graphite_web']['uri'] = "https://launchpad.net/graphite/0.9/#{node['graphite']['version']}/+download/graphite-web-#{node['graphite']['version']}.tar.gz"
  21
+default['graphite']['graphite_web']['checksum'] = "4fd1d16cac3980fddc09dbf0a72243c7ae32444903258e1b65e28428a48948be"
  22
+
  23
+default['graphite']['carbon']['uri'] = "https://launchpad.net/graphite/0.9/#{node['graphite']['version']}/+download/carbon-#{node['graphite']['version']}.tar.gz"
  24
+default['graphite']['carbon']['checksum'] = "4f37e00595b5b078edb9b3f5cae318f752f4446a82623ea4da97dd7d0f6a5072"
  25
+default['graphite']['carbon']['line_receiver_interface'] =   "0.0.0.0"
  26
+default['graphite']['carbon']['line_receiver_port'] = 2003
  27
+default['graphite']['carbon']['pickle_receiver_interface'] = "0.0.0.0"
  28
+default['graphite']['carbon']['pickle_receiver_port'] = 2004
  29
+default['graphite']['carbon']['cache_query_interface'] =     "0.0.0.0"
  30
+default['graphite']['carbon']['cache_query_port'] = 7002
  31
+default['graphite']['carbon']['max_updates_per_second'] = 1000
  32
+default['graphite']['carbon']['service_type'] = "runit"
  33
+default['graphite']['carbon']['log_whisper_updates'] = "False"
  34
+
  35
+default['graphite']['encrypted_data_bag']['name'] = nil
11  metadata.rb
... ...
@@ -1,17 +1,18 @@
  1
+name             "graphite"
1 2
 maintainer       "Heavy Water Software Inc."
2 3
 maintainer_email "ops@hw-ops.com"
3 4
 license          "Apache 2.0"
4 5
 description      "Installs/Configures graphite"
5 6
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
6  
-version          "0.3.1"
  7
+version          "0.4.0"
7 8
 
8 9
 supports "ubuntu"
9 10
 
10  
-depends "python"
11  
-depends "apache2"
  11
+depends  "python"
  12
+depends  "apache2"
  13
+depends  "runit"
  14
+depends  "memcached"
12 15
 
13  
-suggests "runit"
14 16
 suggests "systemd"
15 17
 suggests "s6"
16  
-
17 18
 suggests "graphiti"
54  recipes/carbon.rb
... ...
@@ -1,32 +1,57 @@
  1
+#
  2
+# Cookbook Name:: graphite
  3
+# Recipe:: carbon
  4
+#
  5
+# Copyright 2011, Heavy Water Software Inc.
  6
+#
  7
+# Licensed under the Apache License, Version 2.0 (the "License");
  8
+# you may not use this file except in compliance with the License.
  9
+# You may obtain a copy of the License at
  10
+#
  11
+#     http://www.apache.org/licenses/LICENSE-2.0
  12
+#
  13
+# Unless required by applicable law or agreed to in writing, software
  14
+# distributed under the License is distributed on an "AS IS" BASIS,
  15
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16
+# See the License for the specific language governing permissions and
  17
+# limitations under the License.
  18
+#
  19
+
1 20
 package "python-twisted"
2 21
 package "python-simplejson"
3 22
 
4 23
 version = node['graphite']['version']
5  
-pyver = node['graphite']['python_version']
  24
+pyver = node['languages']['python']['version'][0..-3]
6 25
 
7  
-remote_file "/usr/src/carbon-#{version}.tar.gz" do
  26
+remote_file "#{Chef::Config[:file_cache_path]}/carbon-#{version}.tar.gz" do
8 27
   source node['graphite']['carbon']['uri']
9 28
   checksum node['graphite']['carbon']['checksum']
10 29
 end
11 30
 
12 31
 execute "untar carbon" do
13 32
   command "tar xzf carbon-#{version}.tar.gz"
14  
-  creates "/usr/src/carbon-#{version}"
15  
-  cwd "/usr/src"
  33
+  creates "#{Chef::Config[:file_cache_path]}/carbon-#{version}"
  34
+  cwd Chef::Config[:file_cache_path]
16 35
 end
17 36
 
18 37
 execute "install carbon" do
19 38
   command "python setup.py install"
20 39
   creates "#{node['graphite']['base_dir']}/lib/carbon-#{version}-py#{pyver}.egg-info"
21  
-  cwd "/usr/src/carbon-#{version}"
  40
+  cwd "#{Chef::Config[:file_cache_path]}/carbon-#{version}"
22 41
 end
23 42
 
24 43
 template "#{node['graphite']['base_dir']}/conf/carbon.conf" do
25 44
   owner node['apache']['user']
26 45
   group node['apache']['group']
27 46
   variables( :line_receiver_interface => node['graphite']['carbon']['line_receiver_interface'],
  47
+             :line_receiver_port => node['graphite']['carbon']['line_receiver_port'],
28 48
              :pickle_receiver_interface => node['graphite']['carbon']['pickle_receiver_interface'],
29  
-             :cache_query_interface => node['graphite']['carbon']['cache_query_interface'] )
  49
+             :pickle_receiver_port => node['graphite']['carbon']['pickle_receiver_port'],
  50
+             :cache_query_interface => node['graphite']['carbon']['cache_query_interface'],
  51
+             :cache_query_port => node['graphite']['carbon']['cache_query_port'],
  52
+             :max_updates_per_second => node['graphite']['carbon']['max_updates_per_second'],
  53
+             :log_whisper_updates => node['graphite']['carbon']['log_whisper_updates'],
  54
+             :storage_dir => node['graphite']['storage_dir'])
30 55
   notifies :restart, "service[carbon-cache]"
31 56
 end
32 57
 
@@ -35,17 +60,22 @@
35 60
   group node['apache']['group']
36 61
 end
37 62
 
38  
-execute "carbon: change graphite storage permissions to apache user" do
39  
-  command "chown -R www-data:www-data #{node['graphite']['base_dir']}/storage"
40  
-  only_if do
41  
-    f = File.stat("#{node['graphite']['base_dir']}/storage")
42  
-    f.uid == 0 and f.gid == 0
43  
-  end
  63
+directory node['graphite']['storage_dir'] do
  64
+  owner node['apache']['user']
  65
+  group node['apache']['group']
  66
+  recursive true
  67
+end
  68
+
  69
+directory "#{node['graphite']['storage_dir']}/whisper" do
  70
+  owner node['apache']['user']
  71
+  group node['apache']['group']
  72
+  recursive true
44 73
 end
45 74
 
46 75
 directory "#{node['graphite']['base_dir']}/lib/twisted/plugins/" do
47 76
   owner node['apache']['user']
48 77
   group node['apache']['group']
  78
+  recursive true
49 79
 end
50 80
 
51 81
 service_type = node['graphite']['carbon']['service_type']
21  recipes/carbon_runit.rb
... ...
@@ -1,3 +1,22 @@
  1
+#
  2
+# Cookbook Name:: graphite
  3
+# Recipe:: carbon_runit
  4
+#
  5
+# Copyright 2011, Heavy Water Software Inc.
  6
+#
  7
+# Licensed under the Apache License, Version 2.0 (the "License");
  8
+# you may not use this file except in compliance with the License.
  9
+# You may obtain a copy of the License at
  10
+#
  11
+#     http://www.apache.org/licenses/LICENSE-2.0
  12
+#
  13
+# Unless required by applicable law or agreed to in writing, software
  14
+# distributed under the License is distributed on an "AS IS" BASIS,
  15
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16
+# See the License for the specific language governing permissions and
  17
+# limitations under the License.
  18
+#
  19
+
1 20
 runit_service "carbon-cache" do
2  
-  finish_script true
  21
+  finish true
3 22
 end
19  recipes/carbon_runit_twistd.rb
... ...
@@ -1 +1,20 @@
  1
+#
  2
+# Cookbook Name:: graphite
  3
+# Recipe:: carbon_runit_twistd
  4
+#
  5
+# Copyright 2011, Heavy Water Software Inc.
  6
+#
  7
+# Licensed under the Apache License, Version 2.0 (the "License");
  8
+# you may not use this file except in compliance with the License.
  9
+# You may obtain a copy of the License at
  10
+#
  11
+#     http://www.apache.org/licenses/LICENSE-2.0
  12
+#
  13
+# Unless required by applicable law or agreed to in writing, software
  14
+# distributed under the License is distributed on an "AS IS" BASIS,
  15
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16
+# See the License for the specific language governing permissions and
  17
+# limitations under the License.
  18
+#
  19
+
1 20
 runit_service "twistd-carbon-cache"
1  recipes/default.rb
@@ -18,6 +18,7 @@
18 18
 #
19 19
 
20 20
 include_recipe "python"
  21
+include_recipe "memcached"
21 22
 
22 23
 include_recipe "graphite::whisper"
23 24
 include_recipe "graphite::carbon"
86  recipes/web.rb
... ...
@@ -1,30 +1,62 @@
  1
+#
  2
+# Cookbook Name:: graphite
  3
+# Recipe:: web
  4
+#
  5
+# Copyright 2011, Heavy Water Software Inc.
  6
+#
  7
+# Licensed under the Apache License, Version 2.0 (the "License");
  8
+# you may not use this file except in compliance with the License.
  9
+# You may obtain a copy of the License at
  10
+#
  11
+#     http://www.apache.org/licenses/LICENSE-2.0
  12
+#
  13
+# Unless required by applicable law or agreed to in writing, software
  14
+# distributed under the License is distributed on an "AS IS" BASIS,
  15
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16
+# See the License for the specific language governing permissions and
  17
+# limitations under the License.
  18
+#
  19
+
1 20
 include_recipe "apache2::mod_python"
2 21
 
3 22
 basedir = node['graphite']['base_dir']
  23
+docroot = node['graphite']['doc_root']
  24
+storagedir = node['graphite']['storage_dir']
4 25
 version = node['graphite']['version']
5  
-pyver = node['graphite']['python_version']
  26
+pyver = node['languages']['python']['version'][0..-3]
6 27
 
7  
-package "python-cairo-dev"
8  
-package "python-django"
9  
-package "python-django-tagging"
10  
-package "python-memcache"
11  
-package "python-rrdtool"
  28
+if Chef::Config[:solo]
  29
+  Chef::Log.warn "This recipe uses encrypted data bags. Chef Solo does not support this."
  30
+else
  31
+  if node['graphite']['encrypted_data_bag']['name']
  32
+    data_bag_name = node['graphite']['encrypted_data_bag']['name']
  33
+    password = Chef::EncryptedDataBagItem.load(data_bag_name, "graphite")
  34
+  else
  35
+    password = node['graphite']['password']
  36
+  end
  37
+end
12 38
 
13  
-remote_file "/usr/src/graphite-web-#{version}.tar.gz" do
  39
+%{ python-cairo-dev python-django python-django-tagging python-memcache python-rrdtool }.each do |pkg|
  40
+  package pkg do
  41
+    action :install
  42
+  end
  43
+end
  44
+
  45
+remote_file "#{Chef::Config[:file_cache_path]}/graphite-web-#{version}.tar.gz" do
14 46
   source node['graphite']['graphite_web']['uri']
15 47
   checksum node['graphite']['graphite_web']['checksum']
16 48
 end
17 49
 
18 50
 execute "untar graphite-web" do
19 51
   command "tar xzf graphite-web-#{version}.tar.gz"
20  
-  creates "/usr/src/graphite-web-#{version}"
21  
-  cwd "/usr/src"
  52
+  creates "#{Chef::Config[:file_cache_path]}/graphite-web-#{version}"
  53
+  cwd Chef::Config[:file_cache_path]
22 54
 end
23 55
 
24 56
 execute "install graphite-web" do
25 57
   command "python setup.py install"
26 58
   creates "#{node['graphite']['doc_root']}/graphite_web-#{version}-py#{pyver}.egg-info"
27  
-  cwd "/usr/src/graphite-web-#{version}"
  59
+  cwd "#{Chef::Config[:file_cache_path]}/graphite-web-#{version}"
28 60
 end
29 61
 
30 62
 template "/etc/apache2/sites-available/graphite" do
@@ -33,39 +65,51 @@
33 65
 
34 66
 apache_site "graphite"
35 67
 
36  
-directory "#{basedir}/storage" do
37  
-  owner node['apache']['user']
38  
-  group node['apache']['group']
  68
+apache_site "000-default" do
  69
+  enable false
39 70
 end
40 71
 
41  
-directory "#{basedir}/storage/log" do
42  
-  owner node['apache']['user']
43  
-  group node['apache']['group']
  72
+%w{ webapp whisper }.each do |dir|
  73
+  directory "#{storagedir}/log/#{dir}" do
  74
+    owner node['apache']['user']
  75
+    group node['apache']['group']
  76
+    recursive true
  77
+  end
44 78
 end
45 79
 
46  
-%w{ webapp whisper }.each do |dir|
47  
-  directory "#{basedir}/storage/log/#{dir}" do
  80
+%w{ info.log exception.log access.log error.log }.each do |file|
  81
+  file "#{storagedir}/log/webapp/#{file}" do
48 82
     owner node['apache']['user']
49 83
     group node['apache']['group']
50 84
   end
51 85
 end
52 86
 
  87
+template "#{docroot}/graphite/local_settings.py" do
  88
+  source "local_settings.py.erb"
  89
+  mode 00755
  90
+  variables(:timezone => node['graphite']['timzone'],
  91
+            :base_dir => node['graphite']['base_dir'],
  92
+            :doc_root => node['graphite']['doc_root'],
  93
+            :storage_dir => node['graphite']['storage_dir'] )
  94
+end
  95
+
53 96
 template "#{basedir}/bin/set_admin_passwd.py" do
54 97
   source "set_admin_passwd.py.erb"
55 98
   mode 00755
56 99
 end
57 100
 
58  
-cookbook_file "#{basedir}/storage/graphite.db" do
  101
+cookbook_file "#{storagedir}/graphite.db" do
59 102
   action :create_if_missing
60 103
   notifies :run, "execute[set admin password]"
61 104
 end
62 105
 
63 106
 execute "set admin password" do
64  
-  command "#{basedir}/bin/set_admin_passwd.py root #{node['graphite']['password']}"
  107
+  command "#{basedir}/bin/set_admin_passwd.py root #{password}"
65 108
   action :nothing
66 109
 end
67 110
 
68  
-file "#{basedir}/storage/graphite.db" do
  111
+# This is not done in the cookbook_file above to avoid triggering a password set on permissions changes
  112
+file "#{storagedir}/graphite.db" do
69 113
   owner node['apache']['user']
70 114
   group node['apache']['group']
71 115
   mode 00644
29  recipes/whisper.rb
... ...
@@ -1,19 +1,38 @@
  1
+#
  2
+# Cookbook Name:: graphite
  3
+# Recipe:: whisper
  4
+#
  5
+# Copyright 2011, Heavy Water Software Inc.
  6
+#
  7
+# Licensed under the Apache License, Version 2.0 (the "License");
  8
+# you may not use this file except in compliance with the License.
  9
+# You may obtain a copy of the License at
  10
+#
  11
+#     http://www.apache.org/licenses/LICENSE-2.0
  12
+#
  13
+# Unless required by applicable law or agreed to in writing, software
  14
+# distributed under the License is distributed on an "AS IS" BASIS,
  15
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16
+# See the License for the specific language governing permissions and
  17
+# limitations under the License.
  18
+#
  19
+
1 20
 version = node['graphite']['version']
2  
-pyver = node['graphite']['python_version']
  21
+pyver = node['languages']['python']['version'][0..-3]
3 22
 
4  
-remote_file "/usr/src/whisper-#{version}.tar.gz" do
  23
+remote_file "#{Chef::Config[:file_cache_path]}/whisper-#{version}.tar.gz" do
5 24
   source node['graphite']['whisper']['uri']
6 25
   checksum node['graphite']['whisper']['checksum']
7 26
 end
8 27
 
9 28
 execute "untar whisper" do
10 29
   command "tar xzf whisper-#{version}.tar.gz"
11  
-  creates "/usr/src/whisper-#{version}"
12  
-  cwd "/usr/src"
  30
+  creates "#{Chef::Config[:file_cache_path]}/whisper-#{version}"
  31
+  cwd Chef::Config[:file_cache_path]
13 32
 end
14 33
 
15 34
 execute "install whisper" do
16 35
   command "python setup.py install"
17 36
   creates "/usr/local/lib/python#{pyver}/dist-packages/whisper-#{version}.egg-info"
18  
-  cwd "/usr/src/whisper-#{version}"
  37
+  cwd "#{Chef::Config[:file_cache_path]}/whisper-#{version}"
19 38
 end
12  templates/default/carbon.conf.erb
... ...
@@ -1,5 +1,5 @@
1 1
 [cache]
2  
-LOCAL_DATA_DIR = <%= node['graphite']['base_dir'] %>/storage/whisper/
  2
+LOCAL_DATA_DIR = <%= @storage_dir %>/whisper/
3 3
 
4 4
 # Specify the user to drop privileges to
5 5
 # If this is blank carbon runs as the user that invokes it
@@ -16,7 +16,7 @@ MAX_CACHE_SIZE = inf
16 16
 # prevent over-utilizing the disk and thus starving the rest of the system.
17 17
 # When the rate of required updates exceeds this, then carbon's caching will
18 18
 # take effect and increase the overall throughput accordingly.
19  
-MAX_UPDATES_PER_SECOND = 1000
  19
+MAX_UPDATES_PER_SECOND = <%= @max_updates_per_second %>
20 20
 
21 21
 # Softly limits the number of whisper files that get created each minute.
22 22
 # Setting this value low (like at 50) is a good way to ensure your graphite
@@ -28,17 +28,17 @@ MAX_UPDATES_PER_SECOND = 1000
28 28
 MAX_CREATES_PER_MINUTE = inf
29 29
 
30 30
 LINE_RECEIVER_INTERFACE = <%= @line_receiver_interface %>
31  
-LINE_RECEIVER_PORT = 2003
  31
+LINE_RECEIVER_PORT = <%= @line_receiver_port %>
32 32
 
33 33
 PICKLE_RECEIVER_INTERFACE = <%= @pickle_receiver_interface %>
34  
-PICKLE_RECEIVER_PORT = 2004
  34
+PICKLE_RECEIVER_PORT = <%= @pickle_receiver_port %>
35 35
 
36 36
 CACHE_QUERY_INTERFACE = <%= @cache_query_interface %>
37  
-CACHE_QUERY_PORT = 7002
  37
+CACHE_QUERY_PORT = <%= @cache_query_port %>
38 38
 
39 39
 # By default, carbon-cache will log every whisper update. This can be excessive and
40 40
 # degrade performance if logging on the same volume as the whisper data is stored.
41  
-LOG_UPDATES = True
  41
+LOG_UPDATES = <%= @log_whisper_updates %>
42 42
 
43 43
 
44 44
 # Enable AMQP if you want to receve metrics using an amqp broker
8  templates/default/graphite-vhost.conf.erb
@@ -10,12 +10,12 @@ NameVirtualHost *:<%= node['graphite']['listen_port'] %>
10 10
         ServerAlias <%= [node['graphite']['url_aliases']].flatten.compact.join(" ") %>
11 11
         <% end %>
12 12
         DocumentRoot "<%= node['graphite']['doc_root'] %>"
13  
-        ErrorLog <%= node['graphite']['base_dir'] %>/storage/log/webapp/error.log
14  
-        CustomLog <%= node['graphite']['base_dir'] %>/storage/log/webapp/access.log common
  13
+        ErrorLog <%= node['graphite']['storage_dir'] %>/log/webapp/error.log
  14
+        CustomLog <%= node['graphite']['storage_dir'] %>/log/webapp/access.log common
15 15
 
16 16
         <Location "/">
17 17
                 SetHandler python-program
18  
-                PythonPath "['<%= node['graphite']['base_dir'] %>'] + sys.path"
  18
+                PythonPath "['<%= node['graphite']['doc_root'] %>'] + sys.path"
19 19
                 PythonHandler django.core.handlers.modpython
20 20
                 SetEnv DJANGO_SETTINGS_MODULE graphite.settings
21 21
                 PythonDebug Off
@@ -40,6 +40,6 @@ NameVirtualHost *:<%= node['graphite']['listen_port'] %>
40 40
 	# must change @DJANGO_ROOT@ to be the path to your django
41 41
 	# installation, which is probably something like:
42 42
 	# /usr/lib/python2.6/site-packages/django
43  
-        Alias /media/ "@DJANGO_ROOT@/contrib/admin/media/"
  43
+        Alias /media/ "<%= node['graphite']['django_root'] %>/contrib/admin/media/"
44 44
 
45 45
 </VirtualHost>
199  templates/default/local_settings.py.erb
... ...
@@ -0,0 +1,199 @@
  1
+## Graphite local_settings.py
  2
+# Edit this file to customize the default Graphite webapp settings
  3
+#
  4
+# Additional customizations to Django settings can be added to this file as well
  5
+
  6
+#####################################
  7
+# General Configuration #
  8
+#####################################
  9
+# Set your local timezone (Django's default is America/Chicago)
  10
+# If your graphs appear to be offset by a couple hours then this probably
  11
+# needs to be explicitly set to your local timezone.
  12
+TIME_ZONE = '<%= @timezone %>'
  13
+
  14
+# Override this to provide documentation specific to your Graphite deployment
  15
+#DOCUMENTATION_URL = "http://graphite.readthedocs.org/"
  16
+
  17
+# Logging
  18
+#LOG_RENDERING_PERFORMANCE = True
  19
+#LOG_CACHE_PERFORMANCE = True
  20
+#LOG_METRIC_ACCESS = True
  21
+
  22
+# Enable full debug page display on exceptions (Internal Server Error pages)
  23
+#DEBUG = True
  24
+
  25
+# If using RRD files and rrdcached, set to the address or socket of the daemon
  26
+#FLUSHRRDCACHED = 'unix:/var/run/rrdcached.sock'
  27
+
  28
+# This lists the memcached servers that will be used by this webapp.
  29
+# If you have a cluster of webapps you should ensure all of them
  30
+# have the *exact* same value for this setting. That will maximize cache
  31
+# efficiency. Setting MEMCACHE_HOSTS to be empty will turn off use of
  32
+# memcached entirely.
  33
+#
  34
+# You should not use the loopback address (127.0.0.1) here if using clustering
  35
+# as every webapp in the cluster should use the exact same values to prevent
  36
+# unneeded cache misses. Set to [] to disable caching of images and fetched data
  37
+MEMCACHE_HOSTS = ['127.0.0.1:11211']
  38
+#DEFAULT_CACHE_DURATION = 60 # Cache images and data for 1 minute
  39
+
  40
+
  41
+#####################################
  42
+# Filesystem Paths #
  43
+#####################################
  44
+# Change only GRAPHITE_ROOT if your install is merely shifted from /opt/graphite
  45
+# to somewhere else
  46
+#GRAPHITE_ROOT = '<%= @base_dir %>'
  47
+# Most installs done outside of a separate tree such as /opt/graphite will only
  48
+# need to change these three settings. Note that the default settings for each
  49
+# of these is relative to GRAPHITE_ROOT
  50
+#CONF_DIR = '<%= @base_dir %>/conf'
  51
+STORAGE_DIR = '<%= @storage_dir %>'
  52
+#CONTENT_DIR = '<%= @doc_root %>/content'
  53
+
  54
+# To further or fully customize the paths, modify the following. Note that the
  55
+# default settings for each of these are relative to CONF_DIR and STORAGE_DIR
  56
+#
  57
+## Webapp config files
  58
+#DASHBOARD_CONF = '<%= @base_dir %>/conf/dashboard.conf'
  59
+#GRAPHTEMPLATES_CONF = '<%= @base_dir %>/conf/graphTemplates.conf'
  60
+
  61
+## Data directories
  62
+# NOTE: If any directory is unreadable in DATA_DIRS it will break metric browsing
  63
+#WHISPER_DIR = '<%= @storage_dir %>/whisper'
  64
+#RRD_DIR = '<%= @storage_dir %>/rrd'
  65
+#DATA_DIRS = [WHISPER_DIR, RRD_DIR] # Default: set from the above variables
  66
+#LOG_DIR = '<%= @storage_dir %>/log/webapp'
  67
+#INDEX_FILE = '<%= @storage_dir %>/index'  # Search index file
  68
+
  69
+
  70
+#####################################
  71
+# Email Configuration #
  72
+#####################################
  73
+# This is used for emailing rendered Graphs
  74
+# Default backend is SMTP
  75
+#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  76
+#EMAIL_HOST = 'localhost'
  77
+#EMAIL_PORT = 25
  78
+#EMAIL_HOST_USER = ''
  79
+#EMAIL_HOST_PASSWORD = ''
  80
+#EMAIL_USE_TLS = False
  81
+# To drop emails on the floor, enable the Dummy backend:
  82
+#EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
  83
+
  84
+
  85
+#####################################
  86
+# Authentication Configuration #
  87
+#####################################
  88
+## LDAP / ActiveDirectory authentication setup
  89
+#USE_LDAP_AUTH = True
  90
+#LDAP_SERVER = "ldap.mycompany.com"
  91
+#LDAP_PORT = 389
  92
+#LDAP_URI = "ldaps://ldap.mycompany.com:636"
  93
+#LDAP_SEARCH_BASE = "OU=users,DC=mycompany,DC=com"
  94
+#LDAP_BASE_USER = "CN=some_readonly_account,DC=mycompany,DC=com"
  95
+#LDAP_BASE_PASS = "readonly_account_password"
  96
+#LDAP_USER_QUERY = "(username=%s)"  #For Active Directory use "(sAMAccountName=%s)"
  97
+#
  98
+# If you want to further customize the ldap connection options you should
  99
+# directly use ldap.set_option to set the ldap module's global options.
  100
+# For example:
  101
+#
  102
+#import ldap
  103
+#ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)
  104
+#ldap.set_option(ldap.OPT_X_TLS_CACERTDIR, "/etc/ssl/ca")
  105
+#ldap.set_option(ldap.OPT_X_TLS_CERTFILE, "/etc/ssl/mycert.pem")
  106
+#ldap.set_option(ldap.OPT_X_TLS_KEYFILE, "/etc/ssl/mykey.pem")
  107
+# See http://www.python-ldap.org/ for further details on these options.
  108
+
  109
+## REMOTE_USER authentication. See: https://docs.djangoproject.com/en/dev/howto/auth-remote-user/
  110
+#USE_REMOTE_USER_AUTHENTICATION = True
  111
+
  112
+# Override the URL for the login link (e.g. for django_openid_auth)
  113
+#LOGIN_URL = '/account/login'
  114
+
  115
+
  116
+##########################
  117
+# Database Configuration #
  118
+##########################
  119
+# By default sqlite is used. If you cluster multiple webapps you will need
  120
+# to setup an external database (such as MySQL) and configure all of the webapp
  121
+# instances to use the same database. Note that this database is only used to store
  122
+# Django models such as saved graphs, dashboards, user preferences, etc.
  123
+# Metric data is not stored here.
  124
+#
  125
+# DO NOT FORGET TO RUN 'manage.py syncdb' AFTER SETTING UP A NEW DATABASE
  126
+#
  127
+# The following built-in database engines are available:
  128
+#  django.db.backends.postgresql          # Removed in Django 1.4
  129
+#  django.db.backends.postgresql_psycopg2
  130
+#  django.db.backends.mysql
  131
+#  django.db.backends.sqlite3
  132
+#  django.db.backends.oracle
  133
+#
  134
+# The default is 'django.db.backends.sqlite3' with file 'graphite.db'
  135
+# located in STORAGE_DIR
  136
+#
  137
+# Users with Django 1.2 or greater should use the new dictionary
  138
+# specification as the old database specification style is removed in 1.4
  139
+#DATABASES = {
  140
+#    'default': {
  141
+#        'NAME': '<%= @storage_dir %>/graphite.db',
  142
+#        'ENGINE': 'django.db.backends.sqlite3',
  143
+#        'USER': '',
  144
+#        'PASSWORD': '',
  145
+#        'HOST': '',
  146
+#        'PORT': ''
  147
+#    }
  148
+#}
  149
+#
  150
+# Users still on Django 1.1 must use the old method instead:
  151
+#DATABASE_ENGINE = 'django.db.backends.mysql'
  152
+#DATABASE_NAME = 'graphite'      # Or path to the database file if using sqlite3
  153
+#DATABASE_USER = 'graphite'
  154
+#DATABASE_PASSWORD = 'graphite-is-awesome'
  155
+#DATABASE_HOST = 'mysql.mycompany.com'
  156
+#DATABASE_PORT = '3306'
  157
+
  158
+
  159
+#########################
  160
+# Cluster Configuration #
  161
+#########################
  162
+# (To avoid excessive DNS lookups you want to stick to using IP addresses only in this entire section)
  163
+#
  164
+# This should list the IP address (and optionally port) of the webapp on each
  165
+# remote server in the cluster. These servers must each have local access to
  166
+# metric data. Note that the first server to return a match for a query will be
  167
+# used.
  168
+#CLUSTER_SERVERS = ["10.0.2.2:80", "10.0.2.3:80"]
  169
+
  170
+## These are timeout values (in seconds) for requests to remote webapps
  171
+#REMOTE_STORE_FETCH_TIMEOUT = 6   # Timeout to fetch series data
  172
+#REMOTE_STORE_FIND_TIMEOUT = 2.5  # Timeout for metric find requests
  173
+#REMOTE_STORE_RETRY_DELAY = 60    # Time before retrying a failed remote webapp
  174
+#REMOTE_FIND_CACHE_DURATION = 300 # Time to cache remote metric find results
  175
+
  176
+## Remote rendering settings
  177
+# Set to True to enable rendering of Graphs on a remote webapp
  178
+#REMOTE_RENDERING = True
  179
+# List of IP (and optionally port) of the webapp on each remote server that
  180
+# will be used for rendering. Note that each rendering host should have local
  181
+# access to metric data or should have CLUSTER_SERVERS configured
  182
+#RENDERING_HOSTS = []
  183
+#REMOTE_RENDER_CONNECT_TIMEOUT = 1.0
  184
+
  185
+# If you are running multiple carbon-caches on this machine (typically behind a relay using
  186
+# consistent hashing), you'll need to list the ip address, cache query port, and instance name of each carbon-cache
  187
+# instance on the local machine (NOT every carbon-cache in the entire cluster). The default cache query port is 7002
  188
+# and a common scheme is to use 7102 for instance b, 7202 for instance c, etc.
  189
+#
  190
+# You *should* use 127.0.0.1 here in most cases
  191
+#CARBONLINK_HOSTS = ["127.0.0.1:7002:a", "127.0.0.1:7102:b", "127.0.0.1:7202:c"]
  192
+#CARBONLINK_TIMEOUT = 1.0
  193
+
  194
+#####################################
  195
+# Additional Django Settings #
  196
+#####################################
  197
+# Uncomment the following line for direct access to Django settings such as
  198
+# MIDDLEWARE_CLASSES or APPS
  199
+#from graphite.app_settings import *
2  templates/default/sv-carbon-cache-finish.erb
... ...
@@ -1,5 +1,5 @@
1 1
 #!/bin/sh
2  
-PIDFILE="<%= node['graphite']['base_dir'] %>/storage/carbon-cache-a.pid"
  2
+PIDFILE="<%= node['graphite']['storage_dir'] %>/carbon-cache-a.pid"
3 3
 
4 4
 if [ -e $PIDFILE ]; then
5 5
     rm -v $PIDFILE
2  templates/default/sv-carbon-cache-run.erb
... ...
@@ -1,3 +1,3 @@
1 1
 #!/bin/sh
2 2
 exec 2>&1
3  
-exec chpst -u <%= node['apache']['user'] %>:<%= node['apache']['group'] %> -l <%= node['graphite']['base_dir'] %>/storage/carbon-cache.lock -- <%= node['graphite']['base_dir']%>/bin/carbon-cache.py --debug start
  3
+exec chpst -u <%= node['apache']['user'] %> -l <%= node['graphite']['storage_dir'] %>/carbon-cache.lock -- <%= node['graphite']['base_dir']%>/bin/carbon-cache.py --debug start
2  templates/default/sv-twistd-carbon-cache-run.erb
... ...
@@ -1,3 +1,3 @@
1 1
 #!/bin/sh
2 2
 exec 2>&1
3  
-exec chpst -u <%= node['apache']['user'] %>:<%= node['apache']['group'] %> -l <%= node['graphite']['base_dir'] %>/storage/carbon-cache.lock -- bash -c twistd --nodaemon --umask=0022 carbon-cache -c <%= node['graphite']['base_dir']%>/conf/carbon.conf --instance=a start
  3
+exec chpst -u <%= node['apache']['user'] %> -l <%= node['graphite']['storage_dir'] %>/carbon-cache.lock -- bash -c twistd --nodaemon --umask=0022 carbon-cache -c <%= node['graphite']['base_dir']%>/conf/carbon.conf --instance=a start

0 notes on commit 43aadd7

Please sign in to comment.
Something went wrong with that request. Please try again.