In the /etc/clustershell/groups.conf
file I like to put the following definitions:
[mygroup]
map: sed -n '1,/$GROUP/d;/\[/,$d;/^$/d;p' /etc/clustershell/groups.conf.d/mygroup_poc_cluster.hosts | awk '{print $1}'
all: grep -v "^\[" /etc/clustershell/groups.conf.d/mygroup_poc_cluster.hosts | grep -v ^$
list: grep "^\[" /etc/clustershell/groups.conf.d/mygroup_poc_cluster.hosts | sed -e "s/\[//" -e "s/\]//"
The cluster.hosts
file is generated from the mapr-ansible-roles and looks like this:
[cluster]
ec2-107-23-20-95.compute-1.amazonaws.com
ec2-107-23-99-30.compute-1.amazonaws.com
ec2-107-23-20-46.compute-1.amazonaws.com
ec2-107-23-20-48.compute-1.amazonaws.com
ec2-107-23-20-71.compute-1.amazonaws.com
[hbase_master]
ec2-107-23-20-46.compute-1.amazonaws.com
[hbase_regionserver]
ec2-107-23-20-95.compute-1.amazonaws.com
ec2-107-23-99-30.compute-1.amazonaws.com
ec2-107-23-20-48.compute-1.amazonaws.com
ec2-107-23-20-71.compute-1.amazonaws.com
...etc...
This allows you to list the available groups:
cmatta@ip-172-16-1-58:~/mapr-ansible-roles$ nodeset -s mygroup -l
@mygroup:cluster
@mygroup:hiveserver
@mygroup:hue
@mygroup:impalastatestore
@mygroup:impalacatalog
@mygroup:impalaserver
@mygroup:jobtracker
@mygroup:webserver
@mygroup:tasktracker
@mygroup:metrics
@mygroup:zookeepers
@mygroup:cldb
@mygroup:nfs
@mygroup:fileserver
@mygroup:edge
@mygroup:spark_master
@mygroup:spark_slave
And run commcands on hosts with specific roles:
cmatta@ip-172-16-1-58:~/mapr-ansible-roles$ clush -s mygroup -g cluster date
172.16.1.159: Wed Sep 17 13:18:47 UTC 2014
172.16.1.157: Wed Sep 17 13:18:47 UTC 2014
172.16.1.158: Wed Sep 17 13:18:47 UTC 2014
172.16.1.154: Wed Sep 17 13:18:47 UTC 2014
172.16.1.156: Wed Sep 17 13:18:47 UTC 2014
172.16.1.155: Wed Sep 17 13:18:47 UTC 2014