IBM Support

How to install Ambari agent using Ambari REST API

Question & Answer


Question

How to install Ambari agent using Ambari REST API?

Answer

It is convenient and straightforward to install new Ambari agent for new host in Ambari UI, however, there are situations where it is more appealing and efficient to use the Ambari REST API especially when automation is the primary driver. To begin, make sure passwordless SSH are properly setup from the Ambari server host to the news host(s) with a common SSH key.

Below is the sample curl command:

curl -i -uadmin:admin -H 'X-Requested-By: ambari' -H 'Content-Type: application/json' -X POST -d'{
"verbose":true,
"sshKey":"-----BEGIN RSA PRIVATE KEY-----\nPRIVATE-KEY-CONTENT-HERE\n----END RSA PRIVATE KEY-----\n",
"hosts":[
"yourcompanyhost1.com",
"yourcompanyhost2.com",
"yourcompanyhost3.com"
],
"user":"root"
}' http://localhost:8080/api/v1/bootstrap

Please note that when passing in sshKey as a string, one will need to append new line character “\n” after each line of the RSA key content. For example, if the RSA private key looks like this:

-----BEGIN RSA PRIVATE KEY-----
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccccccccc
-----END RSA PRIVATE KEY-------

The key content should be passed in as
“-----BEGIN RSA PRIVATE KEY-----\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\nccccccccccccccccccccccccccccccc\n-----END RSA PRIVATE KEY-------\n”

Alternatively, to make the passing of the sshKey less error-prone, one can also pass the ssh key file using the --key parameter, eg. --key ˜/.ssh/id_rsa

The bootstrap process executes asynchronously. To check on the bootstrap process, make a GET call against /api/v1/bootstrap/<requestId> as shown below:


curl -i -uadmin:admin http://localhost:8080/api/v1/bootstrap/1

[{"Product":{"code":"SSCRJT","label":"IBM Db2 Big SQL"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"--","Platform":[{"code":"PF016","label":"Linux"}],"Version":"4.1.0;4.2.0","Edition":"Enterprise Edition","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
08 April 2021

UID

swg22000281