Support Questions

Find answers, ask questions, and share your expertise

Automated way of adding a host to an ambari managed cluster.

avatar
Contributor

I am automating the process of recovery of a failed host in a cluster(using python), and I need to add a host to the cluster then I will install components on that.

Ambari has API to add a host e.g.

requests.post(" http://<ambari-host-IP>:<port>/api/v1/clusters/<CLUSTERNAME>/hosts/<HOSTNAME>", auth=self.auth, headers=self.headers, proxies=self.proxyDict)

but it dosent takes ssh key and password.

I dont want to explicitly install abmari agent using YUM(and changing agent.ini config file)because server version and agent version may not match.

Do we have a way to add ssh key and ssh password to above post command.

Or, is there any other automated way to add and register a host to an existing cluster through a python prograam ?

1 ACCEPTED SOLUTION

avatar
7 REPLIES 7

avatar
Super Guru
@Mukesh Burman

Using ambari api/ post command you will not able to install/register new host to the cluster.

To achieve this you need to write custom python script and get the steps done as mentioned in - https://cwiki.apache.org/confluence/display/AMBARI/Add+a+host+and+deploy+components+using+APIs

avatar
Super Guru

@Mukesh Burman You can also check Ambari Blueprints for automation

avatar
Contributor

@Sagar Shimpi Many thanks for your reply, but the page u refereed, starts with "Ensure the host is registered properly"

and, I need a way to register a host with ssh key and password, so that ambari server can install ambari agent on new host.

without ssh key and password, ambari server fails to to so, In ambari UI there is an option to put a ssh key and password but how to do that using curl command ?

avatar

avatar
Contributor

@Rahul Pathak I already tried this, but after submitting bootstrap request, it never returns a failure or success response, I always get a running status, although, I carried on further and saw that ambari agent was installed successfully(despite of not getting a failure/success response). And like this my job is done. 🙂

Thanks man

avatar

@Mukesh Burman

I guess you can accept my answer. 🙂

avatar
Contributor

Oops! my bad...

Did it 🙂