Using the Ops Manager CLI

Page last updated:

This topic describes how to use the Ops Manager command line interface (om CLI) to perform common Ops Manager operations.

About om CLI

om CLI is a tool that helps you configure and deploy tiles to Ops Manager without using the Ops Manager UI. om CLI communicates with the Ops Manager API and makes commands simpler.

With the om CLI, you can also manage Ops Manager programmatically through platform automation. For more information about platform automation, see the Platform Automation Toolkit.

The om CLI has the following benefits over the Ops Manager API:

  • You can om curl Ops Manager API calls with easier authentication

  • om CLI commands are easier to use and memorize

  • om CLI output can be easier to parse

For more information about using the om CLI, see om in GitHub.

Install om CLI

You can install the om CLI in one of the following ways:

Install om CLI Using Homebrew

If you are on a Mac or Linux machine, you can use Homebrew to install the om CLI. You must first have Homebrew installed to use this method.

To install the om CLI using Homebrew:

  1. Download the om CLI.

    brew tap pivotal-cf/om https://github.com/pivotal-cf/om
    
  2. Install the om CLI.

    brew install om
    
  3. Test your installation.

    om version
    

Install om CLI from Direct Download

You can install the om CLI directly from the om CLI GitHub repo.

To install the om CLI from direct download:

  1. Go to the om CLI releases in GitHub and choose your release.

  2. Download the release from Assets. Choose the asset that corresponds with your operating system. For example, download om-windows-x.x.x.zip for Windows machines.

  3. Unzip your file if needed and run the executable file.

  4. Wait for your machine to prompt that the installation is complete.

  5. Test your installation by opening a Shell window and running om version.

Authenticate with the om CLI

For most om CLI commands, you must authenticate with Ops Manager by putting your Ops Manager login information into a YAML file.

To authenticate with the om CLI:

  1. In your workspace, create a YAML file that represents your Ops Manager environment. Give the file a name. For example:

    touch om-cli-env.yml
    
  2. Add the following content to the file. For more information about configuring the file, see Generating an Env File in the Platform Automation Toolkit documentation.

    ---
    target: https://OPS-MANAGER-FQDN
    username: OPS-MANAGER-USERNAME
    password: OPS-MANAGER-PASSWORD
    

    Where:

    • OPS-MANAGER-FQDN is the FQDN of your Ops Manager deployment.
    • OPS-MANAGER-USERNAME is the username that you use when you log into the Ops Manager UI.
    • OPS-MANAGER-PASSWORD is the password that you use when you log into the Ops Manager UI.
  3. On your machine, set an environment variable to the absolute filepath of your environment file for easy access.

    export OM_ENV=PATH-TO-WORKING-DIRECTORY/om-cli-env.yml
    
  4. Test authentication in your Ops Manager environment by running the om products command.

    om --env=$OM_ENV products
    

    If successful, see product output. For example:

    +----------------------+---------------+------------------+------------------+
    |         NAME         |   AVAILABLE   |      STAGED      |     DEPLOYED     |
    +----------------------+---------------+------------------+------------------+
    | cf                   | 2.10.12       | 2.10.12          | 2.10.12          |
    | p-bosh               |               | 2.10.8-build.168 | 2.10.8-build.168 |
    | pivotal-telemetry-om | 1.1.2-build.2 |                  |                  |
    +----------------------+---------------+------------------+------------------+

om CLI Commands

For a list of all om CLI commands, see Commands in the om CLI GitHub documentation.