Created
August 1, 2013 20:50
-
-
Save binford2k/6135160 to your computer and use it in GitHub Desktop.
simple mco agent
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
module MCollective | |
module Agent | |
class Netserv<RPC::Agent | |
metadata :name => "netserv", | |
:description => "Network services for MCollective", | |
:author => "Ben Ford", | |
:license => "GPLv2", | |
:version => "1.1", | |
:url => "http://www.puppetlabs.com.com/education", | |
:timeout => 60 | |
# Basic motd server | |
action "motd" do | |
reply[:msg] = File.read('/etc/motd') | |
end | |
action "finger" do | |
validate :user, String | |
plan = "/home/#{request[:user]}/.plan" | |
reply.fail "No .plan file for user" unless File.exists?(plan) | |
# check all the validation(s) passed before doing any work | |
return unless reply.statuscode == 0 | |
reply[:msg] = File.read(plan) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In current mco, you'd omit the metadata hash