Skip to content

Instantly share code, notes, and snippets.

@ferki
Created May 11, 2015 14:46
Show Gist options
  • Save ferki/3b45586cb50114457d90 to your computer and use it in GitHub Desktop.
Save ferki/3b45586cb50114457d90 to your computer and use it in GitHub Desktop.
[foo]
machine-1.domain.tld port=23
machine-2.domain.tld port=24
$ rex -G foo uptime
[2015-05-11 16:45:53] INFO - Running task uptime on machine-1.domain.tld
[2015-05-11 16:45:53] INFO - Connecting to machine-1.domain.tld:23 (root)
[2015-05-11 16:45:54] WARN - Can't connect to machine-1.domain.tld (unable to establish master SSH connection: master process exited unexpectedly)
[2015-05-11 16:45:54] WARN - Error running task/batch: Wrong username/password or wrong key on machine-1.domain.tld. Or root is not permitted to login over SSH. at /home/ferki/perl5/perlbrew/perls/perl-5.20.2/lib/site_perl/5.20.2/Rex/TaskList/Base.pm line 295.
[2015-05-11 16:45:54] INFO - Running task uptime on machine-2.domain.tld
[2015-05-11 16:45:54] INFO - Connecting to machine-2.domain.tld:24 (root)
[2015-05-11 16:45:56] WARN - Can't connect to machine-2.domain.tld (unable to establish master SSH connection: master process exited unexpectedly)
[2015-05-11 16:45:56] WARN - Error running task/batch: Wrong username/password or wrong key on machine-2.domain.tld. Or root is not permitted to login over SSH. at /home/ferki/perl5/perlbrew/perls/perl-5.20.2/lib/site_perl/5.20.2/Rex/TaskList/Base.pm line 295.
[2015-05-11 16:45:56] INFO - Exiting Rex...
[2015-05-11 16:45:56] INFO - Cleaning up...
use Rex -feature => ['1.0'];
use Rex::Commands::Virtualization;
use Data::Dumper;
#parallelism 10;
use Rex::Group::Lookup::INI;
groups_file "hosts.ini";
user "root";
private_key "/home/ferki/.ssh/id_rsa";
public_key "/home/ferki/.ssh/id_rsa.pub";
set virtualization => "Docker";
desc "Get the uptime of all servers.";
task "uptime",
group => "containers",
sub {
my $output = run 'echo $HOSTNAME $(uptime)';
say $output;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment