diff --git a/Changes b/Changes index f061aed..7358f2f 100644 --- a/Changes +++ b/Changes @@ -1,8 +1,12 @@ -0.025 -- update variable format check to \w[-\.\w]* -- added SSH_BATCH_PASSPHRASE for -P and SSH_BATCH_PASSWORD env for -w -- added passphrase support -- added some doc for tty option +0.027 +- added support for the environment SSH_BATCH_RC to specify a + different file name than the default ~/.fornodesrc. + thanks Mithun Ayachit. +- updated host variable format check to /\w[-\.\w]*/. +- added the SSH_BATCH_PASSPHRASE environment for -P and + SSH_BATCH_PASSWORD env for -w. +- added passphrase support. +- added some doc for tty option. 0.024 - tonodes: added rsync archive, update and compress mode. (liseen) diff --git a/META.yml b/META.yml index 229bc03..9bb8967 100644 --- a/META.yml +++ b/META.yml @@ -1,7 +1,7 @@ --- abstract: 'Cluster operations based on parallel SSH, set and interval arithmetic' author: - - 'Agent Zhang ' + - "Zhang \"agentzh\" Yichun " build_requires: ExtUtils::MakeMaker: 6.42 IPC::Run3: 0 @@ -30,4 +30,4 @@ requires: resources: license: http://opensource.org/licenses/bsd-license.php repository: http://github.com/agentzh/sshbatch -version: 0.026 +version: 0.027 diff --git a/Makefile.PL b/Makefile.PL index 087bd3f..451db14 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -4,7 +4,7 @@ use inc::Module::Install; name ('SSH-Batch'); license ('bsd'); -author ('Agent Zhang '); +author ('Zhang "agentzh" Yichun '); perl_version ('5.006001'); all_from ('lib/SSH/Batch.pm'); diff --git a/README b/README index c8e0186..c4b582b 100644 --- a/README +++ b/README @@ -3,7 +3,7 @@ NAME arithmetic VERSION - This document describes SSH::Batch 0.024 released on Nov 1, 2010. + This document describes SSH::Batch 0.027 released on 25 August 2011. SYNOPSIS The following scripts are provided: @@ -47,9 +47,6 @@ SYNOPSIS # or prompt for password if sudo required... $ atnodes 'sudo apachectl restart' '{ps}' -w - # use -P to prompt for passphrase (no echo back) - $ atnodes hostname '{ps}' -u agentz -P - # run sudo command if tty required... $ atnodes -tty 'sudo apachectl restart' '{ps}' @@ -83,7 +80,8 @@ DESCRIPTION operations: fornodes, atnodes, tonodes, and key2nodes. "SSH::Batch" allows you to name your clusters using variables and - interval/set syntax in your ~/.fornodesrc config file. For instance: + interval/set syntax in your ~/.fornodesrc config file (or a different + file name specified by the "SSH_BATCH_RC" environment). For instance: $ cat ~/.fornodesrc A=foo[01-03].com bar.org @@ -260,6 +258,15 @@ TIPS $ atnodes 'ls -lh' '{B} + bob@bar[29-31].org:5678' + It's also possible to specify a different rc config file than + ~/.fornodesrc via the environment variable "SSH_BATCH_RC". For + example, + + export SSH_BATCH_RC=/opt/my-fornodes-rc + + then the file /opt/my-fornodes-rc will be used instead of the + default ~/.fornodesrc file. + Use "-L" to help grepping the outputs by hostname When managing hundreds or even thousands of machines, it's often more convenient to "grep" over the outputs of atnodes or tonodes by @@ -345,11 +352,11 @@ INSTALLATION Win32 users should replace "make" with "nmake". -SOURCE CONTROL - You can always get the latest SSH::Batch source from its public Git +CODE REPOSITORY + You can always get the latest "SSH::Batch" source from its public Git repository: - http://github.com/agentzh/sshbatch/tree/master + If you have a branch for me to pull, please let me know ;) @@ -366,17 +373,19 @@ TODO * Add the betweennodes script to transfer files between clusters through localhost. -SEE ALSO - fornodes, atnodes, tonodes, key2nodes, SSH::Batch::ForNodes, - Net::OpenSSH. +AUTHORS + * Zhang "agentzh" Yichun (章亦春) "" -COPYRIGHT AND LICENSE + * Liseen Wan (万珣新) "" + +COPYRIGHT & LICENSE This module as well as its programs are licensed under the BSD License. Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved. - Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved. + Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). All rights + reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -406,3 +415,7 @@ COPYRIGHT AND LICENSE NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +SEE ALSO + fornodes, atnodes, tonodes, key2nodes, SSH::Batch::ForNodes, + Net::OpenSSH. + diff --git a/bin/atnodes b/bin/atnodes index 0554514..15c5a6a 100644 --- a/bin/atnodes +++ b/bin/atnodes @@ -10,7 +10,6 @@ use Term::ReadKey; use SSH::Batch::ForNodes; use File::Temp qw/ :POSIX /; use Time::HiRes qw/sleep/; -use IPC::Open3; sub help ($); sub check_openssh_version ($); @@ -330,6 +329,8 @@ sub check_openssh_version ($) { __END__ +=encoding utf-8 + =head1 NAME atnodes - Run commands on clusters @@ -414,13 +415,27 @@ Please refer to L for more documentation. L, L, L, L, L. -=head1 COPYRIGHT AND LICENSE +=head1 AUTHORS + +=over + +=item * + +Zhang "agentzh" Yichun (章亦春) C<< >> + +=item * + +Liseen Wan (万珣新) C<< >> + +=back + +=head1 COPYRIGHT & LICENSE This module as well as its programs are licensed under the BSD License. Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved. -Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved. +Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/bin/fornodes b/bin/fornodes index 17c4007..7a3293b 100644 --- a/bin/fornodes +++ b/bin/fornodes @@ -67,6 +67,8 @@ _EOC_ __END__ +=encoding utf-8 + =head1 NAME fornodes - Expand patterns to machine host list @@ -101,17 +103,27 @@ fornodes - Expand patterns to machine host list Please refer to L for more documentation. -=head1 SEE ALSO +=head1 AUTHORS -L, L, L, L, L. +=over + +=item * + +Zhang "agentzh" Yichun (章亦春) C<< >> + +=item * + +Liseen Wan (万珣新) C<< >> + +=back -=head1 COPYRIGHT AND LICENSE +=head1 COPYRIGHT & LICENSE This module as well as its programs are licensed under the BSD License. -Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved. +Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. -Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved. +Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -133,3 +145,7 @@ Neither the name of the Yahoo! China EEEE Works, Alibaba Inc. nor the names of i THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +=head1 SEE ALSO + +L, L, L, L, L. + diff --git a/bin/key2nodes b/bin/key2nodes index 44688f8..0e6085a 100644 --- a/bin/key2nodes +++ b/bin/key2nodes @@ -253,6 +253,8 @@ _EOC_ } __END__ +=encoding utf-8 + =head1 NAME key2nodes - Push SSH public keys to remote clusters @@ -305,7 +307,7 @@ This module as well as its programs are licensed under the BSD License. Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved. -Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved. +Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/bin/tonodes b/bin/tonodes index 94ff252..1b1a42c 100644 --- a/bin/tonodes +++ b/bin/tonodes @@ -375,6 +375,8 @@ _EOC_ } __END__ +=encoding utf-8 + =head1 NAME tonodes - Upload local files/directories to remote clusters @@ -428,17 +430,27 @@ tonodes - Upload local files/directories to remote clusters Please refer to L for more documentation. -=head1 SEE ALSO +=head1 AUTHORS -L, L, L, L, L. +=over + +=item * + +Zhang "agentzh" Yichun (章亦春) C<< >> + +=item * + +Liseen Wan (万珣新) C<< >> + +=back -=head1 COPYRIGHT AND LICENSE +=head1 COPYRIGHT & LICENSE This module as well as its programs are licensed under the BSD License. Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved. -Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved. +Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -460,3 +472,7 @@ Neither the name of the Yahoo! China EEEE Works, Alibaba Inc. nor the names of i THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +=head1 SEE ALSO + +L, L, L, L, L. + diff --git a/lib/SSH/Batch.pm b/lib/SSH/Batch.pm index ed278a1..2e6e7f2 100644 --- a/lib/SSH/Batch.pm +++ b/lib/SSH/Batch.pm @@ -1,20 +1,24 @@ +# vim:set ft=perl ts=4 sw=4 et + package SSH::Batch; use strict; use warnings; -our $VERSION = '0.025'; +our $VERSION = '0.027'; 1; __END__ +=encoding utf-8 + =head1 NAME SSH::Batch - Cluster operations based on parallel SSH, set and interval arithmetic =head1 VERSION -This document describes SSH::Batch 0.024 released on Nov 1, 2010. +This document describes SSH::Batch 0.027 released on 25 August 2011. =head1 SYNOPSIS @@ -95,7 +99,7 @@ System administration (sysadmin) is also part of my C<$work>. Playing with a (bi This is a high-level abstraction over the powerful L module. A bunch of handy scripts are provided to simplify big cluster operations: L, L, L, and L. -C allows you to name your clusters using variables and interval/set syntax in your F<~/.fornodesrc> config file. For instance: +C allows you to name your clusters using variables and interval/set syntax in your F<~/.fornodesrc> config file (or a different file name specified by the C environment). For instance: $ cat ~/.fornodesrc A=foo[01-03].com bar.org @@ -246,6 +250,12 @@ You may have already learned that you can use the C<-u> and C<-p> options to spe $ atnodes 'ls -lh' '{B} + bob@bar[29-31].org:5678' +It's also possible to specify a different rc config file than F<~/.fornodesrc> via the environment variable C. For example, + + export SSH_BATCH_RC=/opt/my-fornodes-rc + +then the file F will be used instead of the default F<~/.fornodesrc> file. + =item Use C<-L> to help grepping the outputs by hostname When managing hundreds or even thousands of machines, it's often more @@ -333,12 +343,11 @@ There's no spesial requirement on the server side ssh service. Even a non-OpenSS Win32 users should replace "make" with "nmake". -=head1 SOURCE CONTROL +=head1 CODE REPOSITORY -You can always get the latest SSH::Batch source from its -public Git repository: +You can always get the latest C source from its public Git repository: - http://github.com/agentzh/sshbatch/tree/master +L If you have a branch for me to pull, please let me know ;) @@ -367,18 +376,27 @@ localhost. =back -=head1 SEE ALSO +=head1 AUTHORS -L, L, L, L, -L, L. +=over + +=item * -=head1 COPYRIGHT AND LICENSE +Zhang "agentzh" Yichun (章亦春) C<< >> + +=item * + +Liseen Wan (万珣新) C<< >> + +=back + +=head1 COPYRIGHT & LICENSE This module as well as its programs are licensed under the BSD License. Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved. -Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved. +Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -400,3 +418,8 @@ Neither the name of the Yahoo! China EEEE Works, Alibaba Inc. nor the names of i THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +=head1 SEE ALSO + +L, L, L, L, +L, L. + diff --git a/lib/SSH/Batch/ForNodes.pm b/lib/SSH/Batch/ForNodes.pm index a333237..71c3822 100644 --- a/lib/SSH/Batch/ForNodes.pm +++ b/lib/SSH/Batch/ForNodes.pm @@ -1,9 +1,11 @@ +# vim:set ft=perl ts=4 sw=4 et + package SSH::Batch::ForNodes; use strict; use warnings; -our $VERSION = '0.024'; +our $VERSION = '0.027'; use Set::Scalar; use File::HomeDir; @@ -27,14 +29,14 @@ sub clear_universe () { } sub init_rc () { - my $rcfile = $ENV{SSH_BATCH_RC} || q(); - if(! $rcfile){ - my $home = $ENV{SSH_BATCH_HOME} || File::HomeDir->my_home; - if (!defined $home || !-d $home) { - die "Can't find the home for the current user.\n"; - } - $rcfile = "$home/.fornodesrc"; - } + my $rcfile = $ENV{SSH_BATCH_RC} || q(); + if(! $rcfile){ + my $home = $ENV{SSH_BATCH_HOME} || File::HomeDir->my_home; + if (!defined $home || !-d $home) { + die "Can't find the home for the current user.\n"; + } + $rcfile = "$home/.fornodesrc"; + } # auto create $rcfile if $rcfile not exists if (! -e $rcfile) { @@ -275,6 +277,8 @@ sub expand_wildcards ($) { 1; __END__ +=encoding utf-8 + =head1 NAME SSH::Batch::ForNodes - Expand set arithmetic expression to host list @@ -285,23 +289,35 @@ SSH::Batch::ForNodes - Expand set arithmetic expression to host list use SSH::Batch::ForNodes; SSH::Batch::ForNodes::init_rc(); + # read the config file from env SSH_BATCH_RC or directly ~/.fornodesrc + my $set = SSH::Batch::ForNodes::parse_expr($expr); # set is a Set::Scalar instance: for my $host (sort $set->elements) { print "$host\n"; } -=head1 AUTHOR +=head1 AUTHORS + +=over + +=item * + +Zhang "agentzh" Yichun (章亦春) C<< >> -Agent Zhang (agentzh) C<< >> +=item * + +Liseen Wan (万珣新) C<< >> + +=back -=head1 COPYRIGHT AND LICENSE +=head1 COPYRIGHT & LICENSE This module as well as its programs are licensed under the BSD License. Copyright (c) 2009, Yahoo! China EEEE Works, Alibaba Inc. All rights reserved. -Copyright (C) 2009, Agent Zhang (agentzh). All rights reserved. +Copyright (C) 2009, 2010, 2011, Zhang "agentzh" Yichun (章亦春). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: