Created on 12-14-2016 03:54 PM
Ambari REST APIs to add a component in kerberized cluster. I tried and tested these in Ambari 2.4.1 version
Here is an example to install SECONDARY_NAMENODE
1. API to Add a Component
curl -s -H "X-Requested-By:ambari" --user admin:admin -i -X POST -d '{"host_components":[{"HostRoles":{"component_name":"SECONDARY_NAMENODE"}}]}' http://AMBARIHOST:8080/api/v1/clusters/CLUSTERNAME/hosts?Hosts/host_name=COMPONENTHOST
2. API to install the Above added component.
curl -s -H "X-Requested-By:ambari" --user admin:admin -i -X PUT -d '{"RequestInfo":{"context":"Install SECONDARY_NAMENODE","operation_level":{"level":"HOST_COMPONENT","cluster_name":"test","host_name":"COMPONENTHOST","service_name":"HDFS"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://AMBARIHOST:8080/api/v1/clusters/CLUSTERNAME/hosts/COMPONENTHOST/host_components/SECONDARY_NAM...
3. API to provide kerberos credentials.
curl -s -H "X-Requested-By:ambari" --user admin:admin -i -X POST -d '{ "Credential" : { "principal" : "admin/admin", "key" : "admin", "type" : "temporary" } }' http://AMBARIHOST:8080/api/v1/clusters/CLUSTERNAME/credentials/kdc.admin.credential
Note: Replace CLUSTERNAME, AMBARIHOST, COMPONENTHOST with appropriate values