Skip to content

Commit

Permalink
[COOK-492] leverage yum_repo LWRP on redhat flavored systems
Browse files Browse the repository at this point in the history
  • Loading branch information
schisamo committed Apr 23, 2011
1 parent 747cbc8 commit f661250
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
26 changes: 21 additions & 5 deletions cloudkick/README.rdoc → cloudkick/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
= DESCRIPTION:
Description
===========

Installs and configures the Cloudkick Agent, and integrates it with Chef.

= REQUIREMENTS:
Requirements
============

You must be running a platform supported by the Cloudkick Agent - at this time, that means Ubuntu, CentOS or Red Hat.
Platform
--------

= USAGE:
* Debian, Ubuntu
* CentOS, Red Hat, Fedora

Cookbooks
---------

* apt (leverages apt_repository LWRP)
* yum (leverages yum_repository LWRP)

The `apt_repository` and `yum_repository` LWRPs are used from these cookbooks to create the proper repository entries so the cloudkick agent can be downloaded and installed.

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.

Expand Down Expand Up @@ -74,7 +89,8 @@ We automatically add a tag for each Role applied to your node. For example, if

The node will automatically have the 'webserver' and 'database_master' tags within Cloudkick.

= LICENSE & AUTHOR:
License and Author
==================

Author:: Adam Jacob (<adam@opscode.com>)
Author:: Seth Chisamore (<schisamo@opscode.com>)
Expand Down
2 changes: 1 addition & 1 deletion cloudkick/libraries/cloudkick_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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
node = ckb.get("nodes", "node:#{node.name}").nodes.first
data = {
:agent_state => node.agent_state,
:color => node.color,
Expand Down
5 changes: 3 additions & 2 deletions cloudkick/metadata.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "cloudkick",
"description": "Installs/Configures the Cloudkick Agent",
"long_description": "= DESCRIPTION:\n\nInstalls and configures the Cloudkick Agent, and integrates it with Chef.\n\n= REQUIREMENTS:\n\nYou must be running a platform supported by the Cloudkick Agent - at this time, that means Ubuntu, CentOS or Red Hat.\n\n= USAGE:\n\nIn 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.\n\nAssuming you name the role 'cloudkick', here is the required json:\n\n {\n \"name\": \"cloudkick\",\n \"chef_type\": \"role\",\n \"json_class\": \"Chef::Role\",\n \"default_attributes\": {\n\n },\n \"description\": \"Configures Cloudkick\",\n \"run_list\": [\n \"recipe[cloudkick]\"\n ],\n \"override_attributes\": {\n \"cloudkick\": {\n \"oauth_key\": \"YOUR KEY HERE\"\n \"oauth_secret\": \"YOUR SECRET HERE\"\n }\n }\n }\n\nIf you want Cloudkick installed everywhere, we recommend you just add the cloudkick attributes to a base role.\n\nAll of the data about the node from Cloudkick is available in node[:cloudkick] - for example: \n\n \"cloudkick\": {\n \"oauth_key\": \"YOUR KEY HERE\",\n \"oauth_secret\": \"YOUR SECRET HERE\",\n \"data\": {\n \"name\": \"slice204393\",\n \"status\": \"running\",\n \"ipaddress\": \"173.203.83.199\",\n \"provider_id\": \"padc2665\",\n \"tags\": [\n \"agent\",\n \"cloudkick\"\n ],\n \"agent_state\": \"connected\",\n \"id\": \"n87cfc79c5\",\n \"provider_name\": \"Rackspace\",\n \"color\": \"#fffffff\"\n }\n }\n\nOf particular interest is the inclusion of the Cloudkick tags. This will allow you to search Chef via tags placed on nodes within Cloudkick:\n\n $ knife search node 'cloudkick_data_tags:agent' -a fqdn\n {\n \"rows\": [\n {\n \"fqdn\": \"slice204393\",\n \"id\": \"slice204393\"\n }\n ],\n \"start\": 0,\n \"total\": 1\n }\n \nWe automatically add a tag for each Role applied to your node. For example, if your node had a run list of:\n\n \"run_list\": [ \"role[webserver]\", \"role[database_master]\" ]\n\nThe node will automatically have the 'webserver' and 'database_master' tags within Cloudkick.\n\n= LICENSE & AUTHOR:\n\nAuthor:: Adam Jacob (<adam@opscode.com>)\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\nCopyright:: 2010-2011, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
"long_description": "Description\n===========\n\nInstalls and configures the Cloudkick Agent, and integrates it with Chef.\n\nRequirements\n============\n\nPlatform\n--------\n\n* Debian, Ubuntu\n* CentOS, Red Hat, Fedora\n\nCookbooks\n---------\n\n* apt (leverages apt_repository LWRP)\n* yum (leverages yum_repository LWRP)\n\nThe `apt_repository` and `yum_repository` LWRPs are used from these cookbooks to create the proper repository entries so the cloudkick agent can be downloaded and installed.\n\nUsage\n=====\n\nIn 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.\n\nAssuming you name the role 'cloudkick', here is the required json:\n\n {\n \"name\": \"cloudkick\",\n \"chef_type\": \"role\",\n \"json_class\": \"Chef::Role\",\n \"default_attributes\": {\n\n },\n \"description\": \"Configures Cloudkick\",\n \"run_list\": [\n \"recipe[cloudkick]\"\n ],\n \"override_attributes\": {\n \"cloudkick\": {\n \"oauth_key\": \"YOUR KEY HERE\"\n \"oauth_secret\": \"YOUR SECRET HERE\"\n }\n }\n }\n\nIf you want Cloudkick installed everywhere, we recommend you just add the cloudkick attributes to a base role.\n\nAll of the data about the node from Cloudkick is available in node[:cloudkick] - for example: \n\n \"cloudkick\": {\n \"oauth_key\": \"YOUR KEY HERE\",\n \"oauth_secret\": \"YOUR SECRET HERE\",\n \"data\": {\n \"name\": \"slice204393\",\n \"status\": \"running\",\n \"ipaddress\": \"173.203.83.199\",\n \"provider_id\": \"padc2665\",\n \"tags\": [\n \"agent\",\n \"cloudkick\"\n ],\n \"agent_state\": \"connected\",\n \"id\": \"n87cfc79c5\",\n \"provider_name\": \"Rackspace\",\n \"color\": \"#fffffff\"\n }\n }\n\nOf particular interest is the inclusion of the Cloudkick tags. This will allow you to search Chef via tags placed on nodes within Cloudkick:\n\n $ knife search node 'cloudkick_data_tags:agent' -a fqdn\n {\n \"rows\": [\n {\n \"fqdn\": \"slice204393\",\n \"id\": \"slice204393\"\n }\n ],\n \"start\": 0,\n \"total\": 1\n }\n \nWe automatically add a tag for each Role applied to your node. For example, if your node had a run list of:\n\n \"run_list\": [ \"role[webserver]\", \"role[database_master]\" ]\n\nThe node will automatically have the 'webserver' and 'database_master' tags within Cloudkick.\n\nLicense and Author\n==================\n\nAuthor:: Adam Jacob (<adam@opscode.com>)\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\nCopyright:: 2010-2011, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
"maintainer": "Opscode, Inc.",
"maintainer_email": "cookbooks@opscode.com",
"license": "Apache 2.0",
"platforms": {
},
"dependencies": {
"apt": ">= 0.0.0"
"apt": ">= 0.0.0",
"yum": ">= 0.0.0"
},
"recommendations": {
},
Expand Down
3 changes: 2 additions & 1 deletion cloudkick/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs/Configures the Cloudkick Agent"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.0.0"

depends "apt"
depends "yum"

recipe "cloudkick::default", "Installs and configures Cloudkick"

18 changes: 7 additions & 11 deletions cloudkick/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# limitations under the License.
#

case node.platform
case node['platform']
when "ubuntu"
apt_repository "cloudkick" do
uri "http://packages.cloudkick.com/ubuntu"
Expand All @@ -27,14 +27,9 @@
action :add
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
yum_repository "cloudkick" do
url "http://packages.cloudkick.com/redhat/$basearch"
action :add
end
end

Expand Down Expand Up @@ -64,11 +59,12 @@
subscribes :restart, resources(:template => "/etc/cloudkick.conf")
end

gem_package "cloudkick"
gem_package "cloudkick" do
action :install
end

ruby_block "cloudkick data load" do
block do
require 'rubygems'
Gem.clear_paths
require 'cloudkick'
node.set['cloudkick']['data'] = Chef::CloudkickData.get(node)
Expand Down

0 comments on commit f661250

Please sign in to comment.