Support Questions

Find answers, ask questions, and share your expertise

how to use Ambari API to add host to config groups without blueprint?

avatar
Explorer

Hello,

Is there a way I can use Ambari API call to add a host to different yarn config groups or move the host from the Default to customized? I can do it manually like this. But not sure if this feature is supported by API? This would be really helpful!

Thanks!

Meng

1 ACCEPTED SOLUTION

avatar
Super Collaborator

Hi @Meng Meng

Ambari UI si completely driven from Ambari REST API

API call to create a new YARN config group and add a host from default group to it:

curl 'http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/config_groups'   -u admin:admin -H "X-Requested-By: ambari" -i -X POST --data '[{"ConfigGroup":{"group_name":"custom_group","tag":"YARN","description":"This is a custom group","desired_configs":[],"hosts":[{"host_name":"c6401.ambari.apache.org"}]}}]' 

But if a host does not belong to Default config group and belongs to any other custom group and is desired to be moved to another custom config group then first it needs to be removed from prior custom config group and then be added to the desired new custom config group. The same API (use PUT instead of POST method) as mentioned above can be used to first remove it from the previous config group

curl 'http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/config_groups/2' -u admin:admin -H "X-Requested-By: ambari" -i  -X PUT --data '{"ConfigGroup":{"group_name":"custom_group","description":"This is a custom group","tag":"YARN","hosts":[],"desired_configs":[]}}' --compressed

Note: In above mentioned APIs, you need to change ambari-server hostname, cluster name, group_name, description and tag (service name) as applicable in your environment

View solution in original post

3 REPLIES 3

avatar
Super Collaborator

Hi @Meng Meng

Ambari UI si completely driven from Ambari REST API

API call to create a new YARN config group and add a host from default group to it:

curl 'http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/config_groups'   -u admin:admin -H "X-Requested-By: ambari" -i -X POST --data '[{"ConfigGroup":{"group_name":"custom_group","tag":"YARN","description":"This is a custom group","desired_configs":[],"hosts":[{"host_name":"c6401.ambari.apache.org"}]}}]' 

But if a host does not belong to Default config group and belongs to any other custom group and is desired to be moved to another custom config group then first it needs to be removed from prior custom config group and then be added to the desired new custom config group. The same API (use PUT instead of POST method) as mentioned above can be used to first remove it from the previous config group

curl 'http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/config_groups/2' -u admin:admin -H "X-Requested-By: ambari" -i  -X PUT --data '{"ConfigGroup":{"group_name":"custom_group","description":"This is a custom group","tag":"YARN","hosts":[],"desired_configs":[]}}' --compressed

Note: In above mentioned APIs, you need to change ambari-server hostname, cluster name, group_name, description and tag (service name) as applicable in your environment

avatar
Explorer

@jaimin Thank you for the information. This resolved my issue!

avatar
Super Collaborator

@Meng Meng

Glad to know that. Please accept the above answer when you get chance, so it can be noted as correct answer to this issue.