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

Clojure-Control 是一个轻量级的远程任务执行工具,仅依赖于 OpenSSH 和 Clojure,允许用户定义集群和任务,并在一台或多台远程机器上执行。通过简单的配置即可实现远程获取日期、文件复制等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

update: Allow passing command line arguments to task now.

1.What is clojure-control?

    The idea came from node-control.
    Define clusters and tasks for system administration or code deployment, then execute them on one or many remote machines.
    Clojure-control depends only on OpenSSH and clojure on the local control machine.Remote machines simply need a standard sshd daemon.

2.Quick example

Get the current date from the two machines listed in the 'mycluster'  config with a single command:

     (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)

    If saved in a file named "controls.clj",run with   

java  - cp clojure.jar:clojure - contrib.jar:control - 0.1 - SNAPSHOT.jar clojure.main controls.clj mycluster date

    Each machine execute "date" command ,and the output form the remote machine is printed to the console.Exmaple console output

 

    Performing mycluster
    Performing date 
for  a.domain.com
    a.domain.com:ssh: date
    a.domain.com:stdout: Sun Jul 
24   19 : 14 : 09  CST  2011
    a.domain.com:exit: 
0
    Performing date 
for  b.domain.com
    b.domain.com:ssh: date
    b.domain.com:stdout: Sun Jul 
24   19 : 14 : 09  CST  2011
    b.domain.com:exit: 
0

    Each line of output is labeled with the address of the machine the command was executed on. The actual command sent and the user used to send it is displayed. stdout and stderr output of the remote process is identified as well as the final exit code of the local ssh command.


3.How to scp files?
    Let's define a new task named deploy

  (task :deploy  " scp files to remote machines "
        []
        (scp (
" release1.tar.gz "   " release2.tar.gz " " /home/alogin/ " ))

    Then it will copy release1.tar.gz and release2.tar.gz to remote machine's /home/alogin directory.

4.Where is it?

    It's on github,https://github.com/killme2008/clojure-control

    Any suggestion or bug reports welcomed.

文章转自庄周梦蝶  ,原文发布时间2011-07-24

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值