This feature is available after the 1.6.1. version of Ambari

The Ambari Shell's aim is to provide an interactive command line tool which supports: -
  • all functionality available through Ambari web-app 
  • context aware command availability 
  • tab completion  
  • required/optional parameter support
Architecture
The shell is written is Java, and uses the Groovy bases Ambari REST client, and the Spring Shell framework.
Ambari-Shell is distributed as a single-file executable jar. The **uber jar**
is generated with the help of spring-boot-maven-plugin available at: http://docs.spring.io/spring-boot/docs/1.0.1.RELEASE/reference/htmlsingle/#executable-jar
Spring-Boot also provides a helper to launch those jars: http://docs.spring.io/spring-boot/docs/1.0.1.RELEASE/reference/htmlsingle/#executable-jar-launching).
After compiling the project, the shell is ready to use (make sure you use Java 7 or above).

 

>> java -jar ambari-shell/target/ambari-shell-1.3.0-SNAPSHOT.jar --ambari.server=localhost --ambari.port=8080 --ambari.user=admin --ambari.password=admin

    _                _                   _  ____   _            _  _
   / \    _ __ ___  | |__    __ _  _ __ (_)/ ___| | |__    ___ | || |
  / _ \  | '_ ` _ \ | '_ \  / _` || '__|| |\___ \ | '_ \  / _ \| || |
 / ___ \ | | | | | || |_) || (_| || |   | | ___) || | | ||  __/| || |
/_/   \_\|_| |_| |_||_.__/  \__,_||_|   |_||____/ |_| |_| \___||_||_|

Welcome to Ambari Shell. For assistance press tab or use the `hint` command.

For the list of available commands type help
 
ambari-shell>help
* blueprint add - Add a new blueprint with either --url or --file
* blueprint defaults - Adds the default blueprints to Ambari
* blueprint list - Lists all known blueprints
* blueprint show - Shows the blueprint by its id
* cluster assign - Assign host to host group
* cluster autoAssign - Automatically assigns hosts to different host groups base on the provided strategy
* cluster build - Starts to build a cluster
* cluster create - Create a cluster based on current blueprint and assigned hosts
* cluster delete - Delete the cluster
* cluster preview - Shows the currently assigned hosts
* cluster reset - Clears the host - host group assignments
* configuration download - Downloads the desired configuration
* configuration modify - Modify the desired configuration
* configuration set - Sets the desired configuration
* configuration show - Prints the desired configuration
* debug off - Stops showing the URL of the API calls
* debug on - Shows the URL of the API calls
* exit - Exits the shell
* hello - Prints a simple elephant to the console
* help - List all commands usage
* hint - Shows some hints
* host components - Lists the components assigned to the selected host
* host focus - Sets the useHost to the specified host
* host list - Lists the available hosts
* quit - Exits the shell
* script - Parses the specified resource file and executes its commands
* services components - Lists all services with their components
* services list - Lists the available services
* services start - Starts a service/all the services
* services stop - Stops a service/all the running services
* tasks - Lists the Ambari tasks
* version - Displays shell version

Please note that all commands are context aware - and are available only when it makes sense. 
For example the `cluster create` command is not available until a `blueprint` has not been added or selected. 
A good approach is to use the `hint` command - as the Ambari UI, this will give you hints about the available commands and the flow of 
creating or configuring a cluster. You can always use TAB for completion or available parameters.
 
ambari-shell>hello

                    .-.._
              __  /`     '.
           .-'  `/   (   a \
          /      (    \,_   \
         /|       '---` |\ =|
        ` \    /__.-/  /  | |
           |  / / \ \  \   \_\
           |__|_|  |_|__\


ambari-shell>blueprint defaults
 
  BLUEPRINT              STACK
  ---------------------  -------
  multi-node-hdfs-yarn   HDP:2.0
  single-node-hdfs-yarn  HDP:2.0
 
ambari-shell>cluster build --blueprint single-node-hdfs-yarn
ambari-shell>cluster assign --hostGroup host_group_1 --host server.ambari.com
 
	HOSTGROUP     HOST
  ------------  -----------------
  host_group_1  server.ambari.com

ambari-shell>cluster create
ambari-shell>tasks
 
  TASK                        STATUS
  --------------------------  -------
  HISTORYSERVER INSTALL       QUEUED
  ZOOKEEPER_SERVER START      PENDING
  ZOOKEEPER_CLIENT INSTALL    PENDING
  HDFS_CLIENT INSTALL         PENDING
  HISTORYSERVER START         PENDING
  NODEMANAGER INSTALL         QUEUED
  NODEMANAGER START           PENDING
  ZOOKEEPER_SERVER INSTALL    QUEUED
  YARN_CLIENT INSTALL         PENDING
  NAMENODE INSTALL            QUEUED
  RESOURCEMANAGER INSTALL     QUEUED
  NAMENODE START              PENDING
  RESOURCEMANAGER START       PENDING
  DATANODE START              PENDING
  SECONDARY_NAMENODE START    PENDING
  DATANODE INSTALL            QUEUED
  MAPREDUCE2_CLIENT INSTALL   PENDING
  SECONDARY_NAMENODE INSTALL  QUEUED
 
Summary
To sum it up in less than two minutes watch this video: https://asciinema.org/a/9783

 

  • No labels