Created
November 8, 2013 09:24
-
-
Save krimdomu/7368520 to your computer and use it in GitHub Desktop.
get servers out of a group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| group servers => "db", "frontend[01..04]"; | |
| task "test", sub { | |
| # this returns the content of the group as is. so the frontend servers | |
| # don't get parsed to frontend01, frontend02, ... | |
| my @servers_raw = Rex::Group->get_group("servers"); | |
| print Dumper(\@servers_raw); | |
| # this will parse the frontend[01..04] into 4 servers | |
| # returning a list of Rex::Group::Entry::Server objects | |
| my @servers = map { $_->get_servers } @servers_raw; | |
| print Dumper(\@servers); | |
| # if the objects are "called" in string context, they will just | |
| # return the server name. | |
| for my $server (@servers) { | |
| print ">> $server\n"; | |
| } | |
| if($servers[0] eq "db") { | |
| print "The first server is 'db'\n"; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment