Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
55 changes: 37 additions & 18 deletions recipes/repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be downloaded from node[:stackdriver][:repo_url] instead? If not then the change you made to support Amazon Linux (which I want badly!) won't do anything as the stackdriver.repo file in this cookbook is the one for the non-Amazon RHEL variants.

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
2 changes: 2 additions & 0 deletions templates/default/stackdriver.list.apt.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Stackdriver agent repository
<%= node[:stackdriver][:repo_url] %>