Skip to content

Instantly share code, notes, and snippets.

@yuta-imai
Created June 9, 2016 11:42
Show Gist options
  • Save yuta-imai/7bdf07ed58b18e7952d4b0da3c6855b5 to your computer and use it in GitHub Desktop.
Save yuta-imai/7bdf07ed58b18e7952d4b0da3c6855b5 to your computer and use it in GitHub Desktop.
#!/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