diff --git a/attributes/default.rb b/attributes/default.rb index 14aef49..fdd8de6 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -6,3 +6,21 @@ default['stackdriver']['api']['key'] = "YOUR_API_KEY_HERE" default['stackdriver']['collectd']['config'] = "yes" + +case node[:platform] +when 'amazon' + default[:stackdriver][:repo_url] = 'http://repo.stackdriver.com/stackdriver-amazonlinux.repo' +when 'redhat', 'centos' + default[:stackdriver][:repo_url] = 'http://repo.stackdriver.com/stackdriver.repo' + +when 'ubuntu' + case node[:platform_version] + when '12.04', '12.10' + default[:stackdriver][:repo_url] = 'deb http://repo.stackdriver.com/apt precise main' + when '10.04' + default[:stackdriver][:repo_url] = 'deb http://repo.stackdriver.com/apt lucid main' + else + default[:stackdriver][:repo_url] = 'deb http://repo.stackdriver.com/apt precise main' + end + +end \ No newline at end of file diff --git a/recipes/repo.rb b/recipes/repo.rb index 98f7905..80acf32 100644 --- a/recipes/repo.rb +++ b/recipes/repo.rb @@ -8,26 +8,45 @@ # All rights reserved # -# Re-make the yum cache vi command resource -execute "create-yum-cache" do - command "yum -q makecache" - action :nothing -end +case node[:platform] +when 'rhel', 'centos', 'amazon' -# Reload the yum cache using the Chef provider -ruby_block "internal-yum-cache-reload" do - block do - Chef::Provider::Package::Yum::YumCache.instance.reload + # Re-make the yum cache vi command resource + execute "create-yum-cache" do + command "yum -q makecache" + action :nothing end - action :nothing -end -# Create the StackDriver yum repo file in yum.repos.d -cookbook_file "/etc/yum.repos.d/stackdriver.repo" do - source "stackdriver.repo" - mode 00644 - notifies :run, "execute[create-yum-cache]", :immediately - notifies :create, "ruby_block[internal-yum-cache-reload]", :immediately -end + # Reload the yum cache using the Chef provider + ruby_block "internal-yum-cache-reload" do + block do + Chef::Provider::Package::Yum::YumCache.instance.reload + end + action :nothing + end + + # Create the StackDriver yum repo file in yum.repos.d + cookbook_file "/etc/yum.repos.d/stackdriver.repo" do + source "stackdriver.repo" + mode 00644 + notifies :run, "execute[create-yum-cache]", :immediately + notifies :create, "ruby_block[internal-yum-cache-reload]", :immediately + end + +when 'ubuntu' + # Create the StackDriver apt repo list + template "/etc/apt/sources.list.d/stackdriver.list" do + source "stackdriver.list.apt.erb" + mode "0644" + owner "root" + group "root" + action :create + end + #update the local package list + execute "stackdriver-apt-get-update" do + command "apt-get update" + action :nothing + end +end diff --git a/templates/default/stackdriver.list.apt.erb b/templates/default/stackdriver.list.apt.erb new file mode 100644 index 0000000..45b3637 --- /dev/null +++ b/templates/default/stackdriver.list.apt.erb @@ -0,0 +1,2 @@ +# Stackdriver agent repository +<%= node[:stackdriver][:repo_url] %> \ No newline at end of file