forked from uwej711/cookbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
= DESCRIPTION: | ||
|
||
Installs and configures the Cloudkick Agent, and integrates it with Chef. | ||
|
||
= REQUIREMENTS: | ||
|
||
You must be running a platform supported by the Cloudkick Agent - at this time, that means Ubuntu, CentOS or Red Hat. | ||
|
||
= USAGE: | ||
|
||
In order for the agent to function, you'll need to have defined your Cloudkick API key and secret. We recommend you do this in a Role, which should also take care of applying the cloudkick::default recipe. | ||
|
||
Assuming you name the role 'cloudkick', here is the required json: | ||
|
||
{ | ||
"name": "cloudkick", | ||
"chef_type": "role", | ||
"json_class": "Chef::Role", | ||
"default_attributes": { | ||
|
||
}, | ||
"description": "Configures Cloudkick", | ||
"run_list": [ | ||
"recipe[cloudkick]" | ||
], | ||
"override_attributes": { | ||
"cloudkick": { | ||
"oauth_key": "YOUR KEY HERE" | ||
"oauth_secret": "YOUR SECRET HERE" | ||
} | ||
} | ||
} | ||
|
||
If you want Cloudkick installed everywhere, we recommend you just add the cloudkick attributes to a base role. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# | ||
# Cookbook Name:: cloudkick | ||
# Attribute:: default | ||
# | ||
# Copyright 2010, Opscode, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
cloudkick_enabled = false | ||
|
||
begin | ||
require 'cloudkick' | ||
cloudkick_enabled = true | ||
rescue LoadError => e | ||
end | ||
|
||
if cloudkick_enabled | ||
set[:cloudkick][:data] = Chef::CloudkickData.get(self) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is where Cloudkick plugins go! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# | ||
# Cookbook Name:: cloudkick | ||
# Library:: cloudkick_data | ||
# | ||
# Copyright 2010, Opscode, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
class Chef | ||
class CloudkickData | ||
def self.get(node) | ||
ckb = Cloudkick::Base.new(node.cloudkick.oauth_key, node.cloudkick.oauth_secret) | ||
node = ckb.get("nodes", "node:#{node.hostname}").nodes.first | ||
data = { | ||
:agent_state => node.agent_state, | ||
:color => node.color, | ||
:id => node.id, | ||
:ipaddress => node.ipaddress, | ||
:name => node.name, | ||
:provider_id => node.provider_id, | ||
:provider_name => node.provider_name, | ||
:status => node.status, | ||
:tags => node.tags | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
maintainer "Opscode, Inc." | ||
maintainer_email "[email protected]" | ||
license "Apache 2.0" | ||
description "Installs/Configures the Cloudkick Agent" | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) | ||
version "0.1.0" | ||
|
||
depends "apt" | ||
|
||
recipe "cloudkick::default", "Installs and configures Cloudkick" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# | ||
# Cookbook Name:: cloudkick | ||
# Recipe:: default | ||
# | ||
# Copyright 2010, Opscode, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
case node.platform | ||
when "ubuntu" | ||
include_recipe "apt" | ||
|
||
execute "curl http://packages.cloudkick.com/cloudkick.packages.key | apt-key add -" do | ||
not_if "apt-key finger | grep '0B80 27BD B5FB A7F1 8FF3 DC1F 2B5E 7CE0 8EE6 154E'" | ||
end | ||
|
||
template "/etc/apt/sources.list.d/cloudkick.com.list" do | ||
mode "0644" | ||
source "cloudkick.com.list.erb" | ||
notifies :run, resources(:execute => "apt-get update"), :immediately | ||
end | ||
when "centos", "redhat" | ||
execute "yum check-update" do | ||
action :nothing | ||
end | ||
|
||
template "/etc/yum.repos.d/cloudkick.repo" do | ||
mode "0644" | ||
source "cloudkick.repo.erb" | ||
notifies :run, resources(:execute => "yum check-update"), :immediately | ||
end | ||
end | ||
|
||
remote_directory "/usr/lib/cloudkick-agent/plugins" do | ||
source "plugins" | ||
mode "0755" | ||
files_mode "0644" | ||
files_backup 0 | ||
recursive true | ||
end | ||
|
||
template "/etc/cloudkick.conf" do | ||
mode "0644" | ||
source "cloudkick.conf.erb" | ||
variables({ | ||
:cloudkick_tags => node.run_list.roles | ||
}) | ||
end | ||
|
||
package "cloudkick-agent" do | ||
action :upgrade | ||
end | ||
|
||
service "cloudkick-agent" do | ||
action [ :enable, :start ] | ||
subscribes :restart, resources(:template => "/etc/cloudkick.conf") | ||
end | ||
|
||
ruby_block "initial cloudkick data load" do | ||
block do | ||
Gem.clear_paths | ||
require 'cloudkick' | ||
node.set[:cloudkick][:data] = Chef::CloudkickData.get(node) | ||
end | ||
action :nothing | ||
end | ||
|
||
gem_package "cloudkick" do | ||
notifies :create, resources(:ruby_block => "initial cloudkick data load"), :immediately | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deb http://packages.cloudkick.com/ubuntu <%= node[:lsb][:codename] %> main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
oauth_key <%= node.cloudkick.oauth_key %> | ||
oauth_secret <%= node.cloudkick.oauth_secret %> | ||
tags <%= @cloudkick_tags.join(",") %> | ||
name <%= node.hostname %> | ||
|