The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

clad - A simple parallel ssh client.

VERSION

version 0.25

SYNOPSIS

    clad [log options] [-n] [-a] [-l login] <cluster> <command>

DESCRIPTION

clad provides the ability to run the same command on several hosts at once. The output is displayed unbuffered as the various hosts run the command. The list of hosts is determined by reading a configuration file which associates names of clusters with lists of hosts. The configuration file may also contain command aliases and environment settings.

The command(s) will be executed under '/bin/sh -e' regardless of the login shell for the remote user.

FEATURES

  • Cluster-specific and global environment settings

  • Event-driven unbuffered output (using Mojo::Reactor)

  • Host chaining support

  • Perlish configuration for dynamic cluster settings

  • Filtering of banners

  • Command aliases

  • Command macros

OPTIONS

-n

Dry run, just show the command that would be executed and each host.

-a

Don't colorize the host names in the output.

-l

Specify a login name for all ssh connections (proxies, too).

EXAMPLES

 clad -n mailhosts uname -a
 clad webservers df -kh
 clad --trace root webservers ping -i 1 localhost

CONFIGURATION

The configuration file is a Clustericious::Config file (YAML or JSON Mojo::Template's ) and has three sections :

env : environment settings for all commands run on all hosts.

clusters : specifies the clusters. A cluster is a label and a list of hosts. Each host can be either a hostname or an array of hostnames. If it is an array of hostnames it will be treated as a sequence of hosts through which to proxy, e.g.

    ssh host1 ssh host2 ssh host3...

If the first proxy host is the same for all the hosts in a cluster, then it can be given separately (see the example below).

aliases : command aliases. These may be either a single command or a list of commands. Lists of commands will all be run in the same ssh session. Environment variables in the env section will be merged with the global environment settings.

macros : command macros. These are a sequence of commands or aliases. They will be executed in sequence, starting a new connection with each one. Each command/alias may also optionally have a login associated with it.

banners : banners which should be suppressed when displaying stderr.

SAMPLE CONFIGURATION

A sample configuration file ~/etc/Clad.conf :

    ---
    env :
        PATH : /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/bin
        PERL5LIB : /home/joe/perl5
    clusters :
        mailers :
            - mail1
            - mail2
            - mail3
        webservers :
            env  :
                USER : bob
            hosts :
                 - web1
                 - web2
        testweb :
            proxy : test.example.com
            hosts :
                - testweb1
                - testweb2
    aliases :
        check_ports : lsof -i -n
        startweb : nginx start
        stopweb : nginx start
        restartweb :
            - apachectl stop
            - apachectl start
        config_pull :
            - cd /usr/local/etc
            - git pull
        build :
            - cd project
            - perl Build.PL
            - ./Build
            - ./Build test
            - ./Build install
    macros :
         release :
            - login : joe
              command : build
            - login : dev
              command : restartweb
     banners :
            - text : |


                **********************************************
                This is a welcome banner that you see whenever
                you ssh to our server!
                **********************************************
                \n
                \n

Another example, using some Mojo::Template features :

    ---
    env :
        PATH : /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/bin
        PERL5LIB : /home/joe/perl5
    clusters :
        mailers    : [ <%= join ',', map "mail".$_, 0..10 %> ],
        webservers : [ <%= `/usr/local/bin/list_my_web_servers` %> ]

NOTES

Manipulating .ssh/config can also be used for proxying. For instance :

    Host webdev1
    ProxyCommand ssh firewall.example.com nc %h %p

    Host webdev2
    ProxyCommand ssh firewall.example.com nc %h %p

SEE ALSO

AUTHOR

original author: Brian Duggan

current maintainer: Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by NASA GSFC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.