[rex-users] How to find the group a server is in

  • From: Alan Batie <alan@xxxxxxxx>
  • To: rex-users@xxxxxxxxxxxxx
  • Date: Wed, 24 Jan 2018 13:03:24 -0800

I would like to have a rex task do things depending on which group the
server is in, but I'm not sure how to fetch the group info for a server?

If I have a server.ini:

[group1]
server1
server2

[group2]
server3
server4

[all_servers]
@group1
@group2

I can get the groups of a server with:

    my @groups = connection->server->group;
    print "host $this_host\n";
    foreach my $group (@groups) {
        print "  --> $group\n";
    }

However, if I use a -H argument, no groups show up, and if I use a -G
argument, that group shows up, e.g. -G all_servers, then the group is
"all_servers" not group1 or group2 as appropriate.


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Other related posts: