From b81fcb53a056133f342d66631149a7c505ecaddb Mon Sep 17 00:00:00 2001 From: Steve Mactaggart Date: Thu, 22 Aug 2013 19:42:54 +1000 Subject: [PATCH 1/2] Added ubuntu support --- attributes/default.rb | 18 +++++++++++++++++ recipes/repo.rb | 46 ++++++++++++++++++++++++++----------------- 2 files changed, 46 insertions(+), 18 deletions(-) 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..c692c91 100644 --- a/recipes/repo.rb +++ b/recipes/repo.rb @@ -8,26 +8,36 @@ # 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 + remote_file "/etc/apt/sources.list.d/stackdriver.list" do + source node[:stackdriver][:repo_url] + end + +end From e0e89b6523d8803b16fd0b50da3090f4c4e70f5c Mon Sep 17 00:00:00 2001 From: Steve Mactaggart Date: Sun, 25 Aug 2013 22:44:01 +1000 Subject: [PATCH 2/2] Updated creation of apt repo from template file. --- recipes/repo.rb | 13 +++++++++++-- templates/default/stackdriver.list.apt.erb | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 templates/default/stackdriver.list.apt.erb diff --git a/recipes/repo.rb b/recipes/repo.rb index c692c91..80acf32 100644 --- a/recipes/repo.rb +++ b/recipes/repo.rb @@ -36,8 +36,17 @@ when 'ubuntu' # Create the StackDriver apt repo list - remote_file "/etc/apt/sources.list.d/stackdriver.list" do - source node[:stackdriver][:repo_url] + 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