Skip to content
Browse files

Use strings to access node attributes rather than symbols

  • Loading branch information...
1 parent ca3bc4c commit 46b53251cd166220f6be86d69e97bb59ab63e7fd @realityforge committed May 30, 2012
View
20 attributes/default.rb
@@ -17,16 +17,16 @@
# limitations under the License.
#
-override[:collectd][:version] = "5.1.0"
-override[:collectd][:url] = "http://collectd.org/files/collectd-#{node[:collectd][:version]}.tar.gz"
+override['collectd']['version'] = "5.1.0"
+override['collectd']['url'] = "http://collectd.org/files/collectd-#{node['collectd']['version']}.tar.gz"
-override[:collectd][:base_dir] = "/opt/collectd"
-override[:collectd][:conf_dir] = "/opt/collectd/etc/conf.d"
-override[:collectd][:plugin_dir] = "/opt/collectd/lib/collectd"
-override[:collectd][:types_db] = ["/opt/collectd/share/collectd/types.db"]
+override['collectd']['base_dir'] = "/opt/collectd"
+override['collectd']['conf_dir'] = "/opt/collectd/etc/conf.d"
+override['collectd']['plugin_dir'] = "/opt/collectd/lib/collectd"
+override['collectd']['types_db'] = ["/opt/collectd/share/collectd/types.db"]
-default[:collectd][:interval] = 10
-default[:collectd][:read_threads] = 5
-default[:collectd][:name] = node[:fqdn]
+default['collectd']['interval'] = 10
+default['collectd']['read_threads'] = 5
+default['collectd']['name'] = node['fqdn']
-default[:collectd][:plugins] = Mash.new
+default['collectd']['plugins'] = Mash.new
View
2 providers/plugin.rb
@@ -21,7 +21,7 @@ def template_map(type)
end
action :create do
- filename = "#{node[:collectd][:conf_dir]}/#{new_resource.name}.conf"
+ filename = "#{node['collectd']['conf_dir']}/#{new_resource.name}.conf"
if new_resource.content
file filename do
owner "root"
View
10 recipes/attribute_driven.rb
@@ -16,11 +16,11 @@
include_recipe "collectd::default"
-node[:collectd][:plugins].each_pair do |plugin_key, definition|
+node['collectd']['plugins'].each_pair do |plugin_key, definition|
collectd_plugin plugin_key.to_s do
- config definition[:config].to_hash if definition[:config]
- template definition[:template].to_s if definition[:template]
- cookbook definition[:cookbook].to_s if definition[:cookbook]
- type definition[:type].to_s if definition[:type]
+ config definition['config'].to_hash if definition['config']
+ template definition['template'].to_s if definition['template']
+ cookbook definition['cookbook'].to_s if definition['cookbook']
+ type definition['type'].to_s if definition['type']
end
end
View
14 recipes/default.rb
@@ -18,19 +18,19 @@
#
execute "install collectd" do
- filename = File.basename(node[:collectd][:url])
- dirname = File.basename(node[:collectd][:url], ".tar.gz")
+ filename = File.basename(node['collectd']['url'])
+ dirname = File.basename(node['collectd']['url'], ".tar.gz")
command <<CMD
cd /usr/src
rm -rf #{dirname}
-wget #{node[:collectd][:url]}
+wget #{node['collectd']['url']}
tar xzf #{filename}
cd #{dirname}
./configure
make
make install
CMD
- creates node[:collectd][:base_dir]
+ creates node['collectd']['base_dir']
end
template "/etc/init.d/collectd" do
@@ -45,21 +45,21 @@
supports :restart => true, :status => true
end
-directory node[:collectd][:base_dir] do
+directory node['collectd']['base_dir'] do
owner "root"
group "root"
mode "755"
recursive true
end
-directory node[:collectd][:conf_dir] do
+directory node['collectd']['conf_dir'] do
owner "root"
group "root"
mode "755"
recursive true
end
-template "#{node[:collectd][:base_dir]}/etc/collectd.conf" do
+template "#{node['collectd']['base_dir']}/etc/collectd.conf" do
source "collectd.conf.erb"
owner "root"
group "root"
View
14 templates/default/collectd.conf.erb
@@ -11,12 +11,12 @@
# You should also read /usr/share/doc/collectd/README.Debian.plugins before
# enabling any more plugins.
-Hostname "<%= node[:collectd][:name] %>"
+Hostname "<%= node['collectd']['name'] %>"
FQDNLookup true
-BaseDir "<%= node[:collectd][:base_dir] %>"
-PluginDir "<%= node[:collectd][:plugin_dir] %>"
-TypesDB "<%= node[:collectd][:types_db].join('", "') %>"
-Interval <%= node[:collectd][:interval] %>
-ReadThreads <%= node[:collectd][:read_threads] %>
+BaseDir "<%= node['collectd']['base_dir'] %>"
+PluginDir "<%= node['collectd']['plugin_dir'] %>"
+TypesDB "<%= node['collectd']['types_db'].join('", "') %>"
+Interval <%= node['collectd']['interval'] %>
+ReadThreads <%= node['collectd']['read_threads'] %>
-Include "<%= node[:collectd][:conf_dir] %>/*.conf"
+Include "<%= node['collectd']['conf_dir'] %>/*.conf"
View
10 templates/default/collectd.init.erb
@@ -26,14 +26,14 @@ DISABLE=0
DESC="statistics collection and monitoring daemon"
NAME=collectd
-DAEMON=<%= node[:collectd][:base_dir] %>/sbin/collectd
+DAEMON=<%= node['collectd']['base_dir'] %>/sbin/collectd
-CONFIGFILE=<%= node[:collectd][:base_dir] %>/etc/collectd.conf
-PIDFILE=<%= node[:collectd][:base_dir] %>/var/run/collectd.pid
+CONFIGFILE=<%= node['collectd']['base_dir'] %>/etc/collectd.conf
+PIDFILE=<%= node['collectd']['base_dir'] %>/var/run/collectd.pid
USE_COLLECTDMON=1
-COLLECTDMON_DAEMON=<%= node[:collectd][:base_dir] %>/sbin/collectdmon
-COLLECTDMON_PIDFILE=<%= node[:collectd][:base_dir] %>/var/run/collectdmon.pid
+COLLECTDMON_DAEMON=<%= node['collectd']['base_dir'] %>/sbin/collectdmon
+COLLECTDMON_PIDFILE=<%= node['collectd']['base_dir'] %>/var/run/collectdmon.pid
MAXWAIT=30

0 comments on commit 46b5325

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