NAME

clad -- A simple parallel ssh client.

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

  • Command aliases

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.

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
    config_pull :
        - cd /usr/local/etc
        - git pull

Another example, using 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

L<Clustericious::Admin>
L<Clustericious::Config>
L<Log::Log4perl::CommandLine>

L<SSH::Batch>, L<Net::OpenSSH::Parallel>, L<Net::SSH::Mechanize>, L<helm>