Ambari Agent can be installed on a number of target hosts via the Ambari REST API if the hosts have been set up for passwordless SSH (as root or a sudo account) with a common SSH key.

See below for an example ("user" is the SSH user account).

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":[
      "c6401.ambari.apache.org",
      "c6402.ambari.apache.org",
      "c6403.ambari.apache.org"
   ],
   "user":"vagrant"
}' http://localhost:8080/api/v1/bootstrap

The server returns the HTTP code 200 (Success) to let the call know that the request has been accepted along with the following response:

{"status":"OK","log":"Running Bootstrap now.","requestId":1}

The bootstrap process itself happens 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

The server responds with the progress:

{"status":"RUNNING","hostsStatus":[{"hostName":"c6401.ambari.apache.org","status":"RUNNING","log":""},{"hostName":"c6402.ambari.apache.org","status":"RUNNING","log":""},{"hostName":"c6403.ambari.apache.org","status":"RUNNING","log":""}],"log":""}

Keep polling on the same URI until you get success or failure.  The output below shows an example of a successful bootstrap result (status == "SUCCESS"):

{"status":"SUCCESS","hostsStatus":[{"hostName":"c6401.ambari.apache.org","status":"DONE","statusCode":"0","log":"==========================\nCreating target directory...\n==========================\n\nCommand start time 2014-09-23 16:50:15\n\nWarning: Permanently added 'c6401.ambari.apache.org,192.168.64.101' (RSA) to the list of known hosts.\nConnection to c6401.ambari.apache.org closed.\nSSH command execution finished\nhost=c6401.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nCopying common functions script...\n==========================\n\nCommand start time 2014-09-23 16:50:16\n\nscp /usr/lib/python2.6/site-packages/ambari_commons\nhost=c6401.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nCopying OS type check script...\n==========================\n\nCommand start time 2014-09-23 16:50:16\n\nscp /usr/lib/python2.6/site-packages/ambari_server/os_check_type.py\nhost=c6401.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nRunning OS type check...\n==========================\n\nCommand start time 2014-09-23 16:50:16\nCluster primary/cluster OS type is redhat6 and local/current OS type is redhat6\n\nConnection to c6401.ambari.apache.org closed.\nSSH command execution finished\nhost=c6401.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nChecking 'sudo' package on remote host...\n==========================\n\nCommand start time 2014-09-23 16:50:16\nsudo-1.8.6p3-7.el6.x86_64\n\nConnection to c6401.ambari.apache.org closed.\nSSH command execution finished\nhost=c6401.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:17\n\n==========================\nCopying repo file to 'tmp' folder...\n==========================\n\nCommand start time 2014-09-23 16:50:17\n\nscp /etc/yum.repos.d/ambari.repo\nhost=c6401.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:17\n\n==========================\nMoving file to repo dir...\n==========================\n\nCommand start time 2014-09-23 16:50:17\n\nConnection to c6401.ambari.apache.org closed.\nSSH command execution finished\nhost=c6401.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:17\n\n==========================\nCopying setup script file...\n==========================\n\nCommand start time 2014-09-23 16:50:17\n\nscp /usr/lib/python2.6/site-packages/ambari_server/setupAgent.py\nhost=c6401.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:18\n\n==========================\nRunning setup agent script...\n==========================\n\nCommand start time 2014-09-23 16:50:18\n/bin/sh: /usr/sbin/ambari-agent: No such file or directory\nRestarting ambari-agent\nVerifying Python version compatibility...\nUsing python  /usr/bin/python2.6\nambari-agent is not running. No PID found at /var/run/ambari-agent/ambari-agent.pid\nVerifying Python version compatibility...\nUsing python  /usr/bin/python2.6\nChecking for previously running Ambari Agent...\nStarting ambari-agent\nVerifying ambari-agent process status...\nAmbari Agent successfully started\nAgent PID at: /var/run/ambari-agent/ambari-agent.pid\nAgent out at: /var/log/ambari-agent/ambari-agent.out\nAgent log at: /var/log/ambari-agent/ambari-agent.log\n('INFO 2014-09-23 16:50:45,762 main.py:83 - loglevel=logging.INFO\nINFO 2014-09-23 16:50:45,764 DataCleaner.py:36 - Data cleanup thread started\nINFO 2014-09-23 16:50:45,767 DataCleaner.py:117 - Data cleanup started\nINFO 2014-09-23 16:50:45,768 DataCleaner.py:119 - Data cleanup finished\nINFO 2014-09-23 16:50:45,817 PingPortListener.py:51 - Ping port listener started on port: 8670\nINFO 2014-09-23 16:50:45,818 main.py:233 - Connecting to Ambari server at https://c6401.ambari.apache.org:8440 (192.168.64.101)\nINFO 2014-09-23 16:50:45,818 NetUtil.py:48 - Connecting to https://c6401.ambari.apache.org:8440/ca\n', None)\n\nConnection to c6401.ambari.apache.org closed.\nSSH command execution finished\nhost=c6401.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:48\n"},{"hostName":"c6402.ambari.apache.org","status":"DONE","statusCode":"0","log":"==========================\nCreating target directory...\n==========================\n\nCommand start time 2014-09-23 16:50:15\n\nWarning: Permanently added 'c6402.ambari.apache.org,192.168.64.102' (RSA) to the list of known hosts.\nConnection to c6402.ambari.apache.org closed.\nSSH command execution finished\nhost=c6402.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nCopying common functions script...\n==========================\n\nCommand start time 2014-09-23 16:50:16\n\nscp /usr/lib/python2.6/site-packages/ambari_commons\nhost=c6402.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nCopying OS type check script...\n==========================\n\nCommand start time 2014-09-23 16:50:16\n\nscp /usr/lib/python2.6/site-packages/ambari_server/os_check_type.py\nhost=c6402.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nRunning OS type check...\n==========================\n\nCommand start time 2014-09-23 16:50:16\nCluster primary/cluster OS type is redhat6 and local/current OS type is redhat6\n\nConnection to c6402.ambari.apache.org closed.\nSSH command execution finished\nhost=c6402.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nChecking 'sudo' package on remote host...\n==========================\n\nCommand start time 2014-09-23 16:50:16\nsudo-1.8.6p3-7.el6.x86_64\n\nConnection to c6402.ambari.apache.org closed.\nSSH command execution finished\nhost=c6402.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nCopying repo file to 'tmp' folder...\n==========================\n\nCommand start time 2014-09-23 16:50:16\n\nscp /etc/yum.repos.d/ambari.repo\nhost=c6402.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:17\n\n==========================\nMoving file to repo dir...\n==========================\n\nCommand start time 2014-09-23 16:50:17\n\nConnection to c6402.ambari.apache.org closed.\nSSH command execution finished\nhost=c6402.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:17\n\n==========================\nCopying setup script file...\n==========================\n\nCommand start time 2014-09-23 16:50:17\n\nscp /usr/lib/python2.6/site-packages/ambari_server/setupAgent.py\nhost=c6402.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:17\n\n==========================\nRunning setup agent script...\n==========================\n\nCommand start time 2014-09-23 16:50:17\n/bin/sh: /usr/sbin/ambari-agent: No such file or directory\nRestarting ambari-agent\nVerifying Python version compatibility...\nUsing python  /usr/bin/python2.6\nambari-agent is not running. No PID found at /var/run/ambari-agent/ambari-agent.pid\nVerifying Python version compatibility...\nUsing python  /usr/bin/python2.6\nChecking for previously running Ambari Agent...\nStarting ambari-agent\nVerifying ambari-agent process status...\nAmbari Agent successfully started\nAgent PID at: /var/run/ambari-agent/ambari-agent.pid\nAgent out at: /var/log/ambari-agent/ambari-agent.out\nAgent log at: /var/log/ambari-agent/ambari-agent.log\n('INFO 2014-09-23 16:50:46,148 main.py:83 - loglevel=logging.INFO\nINFO 2014-09-23 16:50:46,149 DataCleaner.py:36 - Data cleanup thread started\nINFO 2014-09-23 16:50:46,151 DataCleaner.py:117 - Data cleanup started\nINFO 2014-09-23 16:50:46,151 DataCleaner.py:119 - Data cleanup finished\nINFO 2014-09-23 16:50:46,169 PingPortListener.py:51 - Ping port listener started on port: 8670\nINFO 2014-09-23 16:50:46,169 main.py:233 - Connecting to Ambari server at https://c6401.ambari.apache.org:8440 (192.168.64.101)\nINFO 2014-09-23 16:50:46,170 NetUtil.py:48 - Connecting to https://c6401.ambari.apache.org:8440/ca\n', None)\n\nConnection to c6402.ambari.apache.org closed.\nSSH command execution finished\nhost=c6402.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:48\n"},{"hostName":"c6403.ambari.apache.org","status":"DONE","statusCode":"0","log":"==========================\nCreating target directory...\n==========================\n\nCommand start time 2014-09-23 16:50:15\n\nWarning: Permanently added 'c6403.ambari.apache.org,192.168.64.103' (RSA) to the list of known hosts.\nConnection to c6403.ambari.apache.org closed.\nSSH command execution finished\nhost=c6403.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nCopying common functions script...\n==========================\n\nCommand start time 2014-09-23 16:50:16\n\nscp /usr/lib/python2.6/site-packages/ambari_commons\nhost=c6403.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nCopying OS type check script...\n==========================\n\nCommand start time 2014-09-23 16:50:16\n\nscp /usr/lib/python2.6/site-packages/ambari_server/os_check_type.py\nhost=c6403.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nRunning OS type check...\n==========================\n\nCommand start time 2014-09-23 16:50:16\nCluster primary/cluster OS type is redhat6 and local/current OS type is redhat6\n\nConnection to c6403.ambari.apache.org closed.\nSSH command execution finished\nhost=c6403.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nChecking 'sudo' package on remote host...\n==========================\n\nCommand start time 2014-09-23 16:50:16\nsudo-1.8.6p3-7.el6.x86_64\n\nConnection to c6403.ambari.apache.org closed.\nSSH command execution finished\nhost=c6403.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:16\n\n==========================\nCopying repo file to 'tmp' folder...\n==========================\n\nCommand start time 2014-09-23 16:50:16\n\nscp /etc/yum.repos.d/ambari.repo\nhost=c6403.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:17\n\n==========================\nMoving file to repo dir...\n==========================\n\nCommand start time 2014-09-23 16:50:17\n\nConnection to c6403.ambari.apache.org closed.\nSSH command execution finished\nhost=c6403.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:17\n\n==========================\nCopying setup script file...\n==========================\n\nCommand start time 2014-09-23 16:50:17\n\nscp /usr/lib/python2.6/site-packages/ambari_server/setupAgent.py\nhost=c6403.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:17\n\n==========================\nRunning setup agent script...\n==========================\n\nCommand start time 2014-09-23 16:50:17\n/bin/sh: /usr/sbin/ambari-agent: No such file or directory\nRestarting ambari-agent\nVerifying Python version compatibility...\nUsing python  /usr/bin/python2.6\nambari-agent is not running. No PID found at /var/run/ambari-agent/ambari-agent.pid\nVerifying Python version compatibility...\nUsing python  /usr/bin/python2.6\nChecking for previously running Ambari Agent...\nStarting ambari-agent\nVerifying ambari-agent process status...\nAmbari Agent successfully started\nAgent PID at: /var/run/ambari-agent/ambari-agent.pid\nAgent out at: /var/log/ambari-agent/ambari-agent.out\nAgent log at: /var/log/ambari-agent/ambari-agent.log\n('INFO 2014-09-23 16:50:50,387 main.py:83 - loglevel=logging.INFO\nINFO 2014-09-23 16:50:50,388 DataCleaner.py:36 - Data cleanup thread started\nINFO 2014-09-23 16:50:50,389 DataCleaner.py:117 - Data cleanup started\nINFO 2014-09-23 16:50:50,390 DataCleaner.py:119 - Data cleanup finished\nINFO 2014-09-23 16:50:50,410 PingPortListener.py:51 - Ping port listener started on port: 8670\nINFO 2014-09-23 16:50:50,411 main.py:233 - Connecting to Ambari server at https://c6401.ambari.apache.org:8440 (192.168.64.101)\nINFO 2014-09-23 16:50:50,412 NetUtil.py:48 - Connecting to https://c6401.ambari.apache.org:8440/ca\n', None)\n\nConnection to c6403.ambari.apache.org closed.\nSSH command execution finished\nhost=c6403.ambari.apache.org, exitcode=0\nCommand end time 2014-09-23 16:50:53\n"}],"log":"\n\nINFO:root:BootStrapping hosts ['c6401.ambari.apache.org',\n 'c6402.ambari.apache.org',\n 'c6403.ambari.apache.org'] using /usr/lib/python2.6/site-packages/ambari_server cluster primary OS: redhat6 with user 'vagrant' sshKey File /var/run/ambari-server/bootstrap/1/sshKey password File null using tmp dir /var/run/ambari-server/bootstrap/1 ambari: c6401.ambari.apache.org; server_port: 8080; ambari version: 1.7.0\nINFO:root:Executing parallel bootstrap\nINFO:root:Finished parallel bootstrap\n"}

Note that the bootstrap process installs the ambari-agent package and configures /etc/ambari-agent/conf/ambari-agent.ini's server.host property to point to the Ambari Server host.
Completion of bootstrap does not ensure that all the agents have registered with the server.

To ensure that all the agents have registered, poll on the /api/v1/hosts until the response shows all the hosts.

 

  • No labels