A clojure DSL for system admin and deployment with many remote machines

1.Whatisclojure-control?

Theideacamefromnode-control.
Defineclustersandtasksforsystemadministrationorcodedeployment,thenexecutethemononeormanyremotemachines.
Clojure-controldependsonlyonOpenSSHandclojureonthelocalcontrolmachine.Remotemachinessimplyneedastandardsshddaemon.

2.Quickexample

Getthecurrentdatefromthetwomachineslistedinthe‘mycluster’configwithasinglecommand:

(ns samples
(:use [control.core :only [task cluster scp ssh begin]]))
;;define clusters
(cluster :mycluster
:clients [
{ :host "a.domain.com" :user "alogin"}
{ :host "b.domain.com" :user "blogin"}
])
;;define tasks
(task :date ”Get date”
(ssh ”date”))
;;start running
(begin)

Ifsavedinafilenamed“controls.clj”,runwith

java-cpclojure.jar:clojure-contrib.jar:control-0.1-SNAPSHOT.jarclojure.maincontrols.cljmyclusterdate

Eachmachineexecute“date”command,andtheoutputformtheremotemachineisprintedtotheconsole.Exmapleconsoleoutput

Performingmycluster
Performingdatefora.domain.com
a.domain.com:ssh:date
a.domain.com:stdout:SunJul2419:14:09CST2011
a.domain.com:exit:0
Performingdateforb.domain.com
b.domain.com:ssh:date
b.domain.com:stdout:SunJul2419:14:09CST2011
b.domain.com:exit:0

Eachlineofoutputislabeledwiththeaddressofthemachinethecommandwasexecutedon.Theactualcommandsentandtheuserusedtosenditisdisplayed.stdoutandstderroutputoftheremoteprocessisidentifiedaswellasthefinalexitcodeofthelocalsshcommand.


3.Howtoscpfiles?
Let’sdefineanewtasknameddeploy

(task:deploy”scpfilestoremotemachines”
(scp(“release1.tar.gz””release2.tar.gz”)”/home/alogin/”))

Thenitwillcopyrelease1.tar.gzandrelease2.tar.gztoremotemachine’s/home/alogindirectory.

4.Whereisit?

It’songithub,https://github.com/killme2008/clojure-control

Anysuggestionorbugreportswelcomed.

你可能感兴趣的:(example,Files,control,Quick)