Created
June 9, 2016 11:42
-
-
Save yuta-imai/7bdf07ed58b18e7952d4b0da3c6855b5 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
AMBARI="hostname:port" | |
CLUSTER="clustername" | |
EC2=".ec2-list" | |
COMPONENTS=".hdp-components" | |
aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | [.Tags[].Value, .PublicDnsName,.PrivateDnsName] | @tsv' > ${EC2} | |
curl -u admin:admin ${AMBARI}/api/v1/${CLUSTER}/factory/host_components | jq -r '.items[].HostRoles | [.host_name, .component_name] | @tsv' | perl -e 'my %hosts; for(<>){ chomp $_; my($host, $component) > | |
join -t ' ' -1 3 -2 1 -o 1.1,1.2,1.3,2.2 ${EC2} ${COMPONENTS} | |
rm ${EC2} ${COMPONENTS} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment