Skip to content

Commit

Permalink
first pass at a scout agent cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
schisamo committed Jan 12, 2010
1 parent 00efd0c commit 629d54d
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
41 changes: 41 additions & 0 deletions scout_agent/README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
= DESCRIPTION:

Installs the {Scout Agent}[http://scoutapp.com] gem and schedules it to run the {Scout-recommended way (via Cron)}[https://scoutapp.com/info/support#cron].

= REQUIREMENTS:

Debian or Ubuntu preferred. Tested on Ubuntu 8.04 Server LTS, should work on others.

The Scout Agent requires a valid Scout account. You also need a unique server key which is displayed in your Scout accounts 'server settings' tab.

It looks like:

6ecad322-0d17-4cb8-9b2c-a12c4541853f

= ATTRIBUTES:

* scout_agent[:user] - User to run Scout agent under. Will be created if it does not exist. Default is 'scout'.
* scout_agent[:group] - User group to run Scout agent under. Will be created if it does not exist. Default is 'scout'.
* scout_agent[:version] - Gem version to install. Default is 5.0.3.
* scout_agent[:key] - Used to validate your agent when it checks into the Scout server.

= USAGE:

Include the scout_monitor recipe to install Scout Agent and configure a Cron job to run it. Be sure to set the scout_agent[:key] attribute on every node where you want the agent to run.

= LICENSE & AUTHOR:

Author:: Seth Chisamore (<[email protected]>)
Copyright:: 2010, Seth Chisamore

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.
4 changes: 4 additions & 0 deletions scout_agent/attributes/scout_agent.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set_unless[:scout_agent][:user] = "scout"
set_unless[:scout_agent][:group] = "scout"
set_unless[:scout_agent][:version] = '5.0.3'
set_unless[:scout_agent][:scout_bin] = "/usr/bin/scout"
43 changes: 43 additions & 0 deletions scout_agent/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"suggestions": {

},
"license": "Apache 2.0",
"recipes": {
"scout_agent": ""
},
"conflicting": {

},
"dependencies": {

},
"providing": {
"scout_agent": [

]
},
"long_description": "= DESCRIPTION:\n\nInstalls the {Scout Agent}[http://scoutapp.com] gem and schedules it to run the {Scout-recommended way (via Cron)}[https://scoutapp.com/info/support#cron].\n\n= REQUIREMENTS:\n\nDebian or Ubuntu preferred. Tested on Ubuntu 8.04 Server LTS, may work on others.\n\nThe Scout Agent requires a valid Scout account. You also need a unique server key which is displayed in your Scout accounts 'server settings' tab.\n\nIt looks like:\n\n 6ecad322-0d17-4cb8-9b2c-a12c4541853f\n\n= ATTRIBUTES:\n\n* scout_agent[:user] - User to run Scout agent under. Will be created if it does not exist. Default is 'scout'.\n* scout_agent[:group] - User group to run Scout agent under. Will be created if it does not exist. Default is 'scout'.\n* scout_agent[:version] - Gem version to install. Default is 5.0.3.\n* scout_agent[:key] - Used to validate your agent when it checks into the Scout server.\n\n= USAGE:\n\nInclude the scout_monitor recipe to install Scout Agent and configure a Cron job to run it. Be sure to set the scout_agent[:key] attribute on every node where you want the agent to run.\n\n= LICENSE & AUTHOR:\n\nAuthor:: Seth Chisamore (<[email protected]>)\nCopyright:: 2010, Seth Chisamore\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.",
"description": "Installs and configures the Scout Agent",
"platforms": {
"debian": [

],
"ubuntu": [

]
},
"version": "0.1.0",
"replacing": {

},
"maintainer": "Seth Chisaore",
"name": "scout_agent",
"recommendations": {

},
"attributes": {

},
"maintainer_email": "[email protected]"
}
10 changes: 10 additions & 0 deletions scout_agent/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
maintainer "Seth Chisaore"
maintainer_email "[email protected]"
license "Apache 2.0"
description "Installs and configures the Scout Agent"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
version "0.1"

%w{ debian ubuntu}.each do |os|
supports os
end
40 changes: 40 additions & 0 deletions scout_agent/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Cookbook Name:: scout_agent
# Recipe:: default

# create user and group
group node[:scout_agent][:group] do
action [ :create, :manage ]
end
user node[:scout_agent][:user] do
comment "Scout Agent"
gid node[:scout_agent][:group]
home "/home/#{node[:scout_agent][:user]}"
supports :manage_home => true
action [ :create, :manage ]
end

# install scout agent gem
gem_package "scout" do
version node[:scout_agent][:version]
action :install
end

if node[:scout_agent][:key]
# initialize scout gem
bash "initialize scout" do
code <<-EOH
#{node[:scout_agent][:scout_bin]} #{node[:scout_agent][:key]}
EOH
not_if do File.exist?("/var/spool/cron/crontabs/scout") end
end

# schedule scout agent to run via cron
cron "scout_run" do
user node[:scout_agent][:user]
command "#{node[:scout_agent][:scout_bin]} #{node[:scout_agent][:key]}"
only_if do File.exist?("/usr/bin/scout") end
end
else
Chef::Log.info "Add a [:scout_agent][:key] attribute to configure this node's Scout Agent"
end

0 comments on commit 629d54d

Please sign in to comment.