This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.Chapter 2. CLI Tooling
2.1. Overview
				The apb CLI tool helps Ansible Playbook Bundle (APB) authors create, build, and publish their APBs to container registries. It enforces best practices and takes care of the details so they should be easy to deploy.
			
2.2. Installing the Tool
2.2.1. Prerequisites
2.2.1.1. Docker Daemon
						The docker daemon must be correctly installed and running on the system.
					
2.2.1.2. Access Permissions
						You must be logged in via oc as a user with cluster-admin permissions:
					
oc login -u <user> <openshift_server>
$ oc login -u <user> <openshift_server>To add this role to another user, you can run the following as a user that already has such permissions (for example, the system:admin default system user):
oc process -f openshift-permissions.template.yaml \ -p BROKER_NAMESPACE=openshift-ansible-service-broker \ -p GLOBAL_IMAGE_PROJECT=default \ [-p USER=<your_desired_user>] \ | oc create -f -
$ oc process -f openshift-permissions.template.yaml \
  -p BROKER_NAMESPACE=openshift-ansible-service-broker \
  -p GLOBAL_IMAGE_PROJECT=default \
  [-p USER=<your_desired_user>] \ 
  | oc create -f -
						This permission requirement is so that the development lifecycle of the apb tool can function.
					
2.2.2. Installing via RPM
					The APB CLI tool is provided by the apb package, which is available from the rhel-7-server-ose-3.7-rpms channel:
				
sudo yum install apb
$ sudo yum install apb2.2.3. Verifying the Installation
					Run apb help to make sure the tool is installed correctly:
				
2.3. Typical Workflows
2.3.1. Local Registry
					In order to use the OpenShift Container Registry to source APBs, you must have configured the OpenShift Ansible broker to use the local_openshift type registry adapter. See the config section for more information.
				
apb init my-new-apb cd my-new-apb apb build apb push --openshift apb list
$ apb init my-new-apb
$ cd my-new-apb
$ apb build
$ apb push --openshift
$ apb list
					If you are using a namespace other than the default openshift namespace to host your APBs, then you can use the following command:
				
apb push -o --namespace <namespace>
$ apb push -o --namespace <namespace>2.3.2. Remote Registry
					OAB can also be configured to use a remote registry and organization such as docker.io/ansibleplaybookbundle or your own personal account. In order to use this for developing APBs, you can build and push to your remote registry and then bootstrap to reload your APBs:
				
2.4. APB Creation Commands
2.4.1. init
Description
Initializes a directory structure for a new APB. Also creates example files for the new APB with sensible defaults.
Usage
apb init [OPTIONS] NAME
$ apb init [OPTIONS] NAMEArguments
					NAME: Name of the APB and directory to be created.
				
Options
| Option, Shorthand | Description | 
|---|---|
| 
									 | Show help message | 
| 
									 | Force re-init and overwrite the directory | 
| 
									 | 
									Specify asynchronous operation on application. Usually defaulted to  | 
| 
									 | Generate an application with bindable settings | 
| 
									 | Do not generate provision playbook and role | 
| 
									 | Do not generate deprovision playbook and role | 
| 
									 | Do not generate bind playbook and role | 
| 
									 | Do not generate unbind playbook and role | 
| 
									 | Do not generate any roles | 
Examples
Create directory my-new-apb:
Create directory my-new-apb, but skip generating deprovision playbook and roles:
Create directory my-new-apb, overwriting any old versions. The APB will be configured to be bindable and require async:
2.4.2. prepare
Description
Compiles the APB into base64 encoding and writes it as a label to the Dockerfile.
					This will allow the OAB to read the APB metadata from the registry without downloading the images. This command must be run from inside the APB directory. Running the build command will automatically run prepare as well, meaning you generally do not need to run prepare by itself.
				
Usage
apb prepare [OPTIONS]
$ apb prepare [OPTIONS]Options
| Option, Shorthand | Description | 
|---|---|
| 
									 | Show help message | 
| 
									 | Writes the APB spec to the target file name instead of a file named Dockerfile | 
Examples
Writes the label for the spec field in the Dockerfile:
apb prepare
$ apb prepareWrites the label for the spec field in Dockerfile-custom:
apb prepare --dockerfile Dockerfile-custom
$ apb prepare --dockerfile Dockerfile-custom2.4.3. build
Description
Builds the image for the APB.
					Similar to running apb prepare and docker build with a tag.
				
Usage
apb build [OPTIONS]
$ apb build [OPTIONS]Options
| Option, Shorthand | Description | 
|---|---|
| 
									 | Show help message | 
| 
									 | 
									Sets the tag of the built image to a string in the format  | 
| 
									 | 
									Registry portion of the tag of the image (e.g.,  | 
| 
									 | User or organization portion of the tag of the image | 
Examples
Build the image and use the name field from apb.yml as the tag:
apb build
$ apb build
					Build the image and use the tag docker.io/my-org/my-new-apb:
				
apb build --tag docker.io/my-org/my-new-apb
$ apb build --tag docker.io/my-org/my-new-apb
					Build the image and use the tag docker.io/my-org/<my-apb-name>:
				
apb build --registry docker.io --org my-org
$ apb build --registry docker.io --org my-orgBuild the image using the file Dockerfile-custom as the Dockerfile definition:
apb build --dockerfile Dockerfile-custom
$ apb build --dockerfile Dockerfile-custom2.4.4. push
Description
Uploads the APB to an OpenShift Container Registry or a broker mock registry where it will be read by the OAB.
					When using the broker’s mock registry, the spec is uploaded and will be displayed in OpenShift Container Platform, but OpenShift Container Platform will pull the image from the registry normally. Usually that means the registry where oc cluster up was performed.
				
When using the OpenShift Container Registry, the image is uploaded to OpenShift Container Platform directly.
Usage
apb push [OPTIONS]
$ apb push [OPTIONS]Options
| Option, Shorthand | Description | 
|---|---|
| 
									 | Show help message | 
| 
									 | Route to the OAB | 
| 
									 | Namespace to push to the OpenShift Container Registry | 
| 
									 | Use the OpenShift Container Registry | 
| 
									 | 
									Dockerfile to build internal registry image. Usually defaults to  | 
| 
									 | Use secure connection to OAB | 
| 
									 | Basic authentication user name to be used in broker communication | 
| 
									 | Basic authentication password to be used in broker communication | 
| 
									 | Do not relist the catalog after pushing an APB to the broker | 
| 
									 | Name of the ServiceBroker Kubernetes resource | 
Examples
Push to the OAB development endpoint:
apb push
$ apb pushPush to the local OpenShift Container Registry:
apb push -o
$ apb push -o
					Push to the local OpenShift Container Registry under namespace myproject:
				
apb push -o --namespace myproject
$ apb push -o --namespace myproject2.4.5. test
Description
Runs the APB unit tests.
Usage
apb test [OPTIONS]
$ apb test [OPTIONS]Options
| Option, Shorthand | Description | 
|---|---|
| 
									 | Show help message | 
| 
									 | 
									Sets the tag of the built image to a string in the format  | 
Examples
Run the tests:
apb test
$ apb testRun the tests but use a specific tag on the built image:
apb test --tag docker.io/my-org/my-new-apb
$ apb test --tag docker.io/my-org/my-new-apb2.5. Broker Utility Commands
2.5.1. list
Description
Lists all the APBs the broker has loaded.
Usage
apb list [OPTIONS]
$ apb list [OPTIONS]Options
| Option, Shorthand | Description | 
|---|---|
| 
									 | Show help message | 
| 
									 | Route to the OAB | 
| 
									 | Use secure connection to OAB | 
| 
									 | Output verbose spec information from OAB | 
| 
									 | Specify verbose output format in yaml (default) or json | 
| 
									 | Specify the basic authentication user name to be used | 
| 
									 | Specify the basic authentication password to be used | 
Examples
Basic list of APBs including name, ID, and description:
apb list
$ apb listList verbose, easily readable specs:
apb list -v
$ apb list -vList all the JSON output:
apb list -v -o json
$ apb list -v -o json2.5.2. bootstrap
Description
Requests the OAB to reload all APBs from the registries.
Usage
apb bootstrap [OPTIONS]
$ apb bootstrap [OPTIONS]Options
| Option, Shorthand | Description | 
|---|---|
| 
									 | Show help message | 
| 
									 | Route to the OAB | 
| 
									 | Use secure connection to OAB | 
| 
									 | Do not relist the catalog after bootstrapping the broker | 
| 
									 | Specify the basic authentication user name to be used | 
| 
									 | Specify the basic authentication password to be used | 
| 
									 | Name of the ServiceBroker Kubernetes resource | 
Examples
Basic reload of APBs:
apb bootstrap
$ apb bootstrap2.5.3. remove
Description
Removes one (or all) APBs from the OAB.
Usage
apb remove [OPTIONS]
$ apb remove [OPTIONS]Options
| Option, Shorthand | Description | 
|---|---|
| 
									 | Show help message | 
| 
									 | Route to the OAB | 
| 
									 | Use secure connection to OAB | 
| 
									 | Remove all stored APBs | 
| 
									 | ID of APB to remove | 
| 
									 | Use secure connection to OAB | 
| 
									 | Specify the basic authentication user name to be used | 
| 
									 | Specify the basic authentication password to be used | 
| 
									 | Do not relist the catalog after deletion | 
Examples
Remove an APB using an ID:
apb remove --id ca91b61da8476984f18fc13883ae2fdb
$ apb remove --id ca91b61da8476984f18fc13883ae2fdbIf you need an ID of an APB, use:
apb list
$ apb list
ID                                NAME                     DESCRIPTION
ca91b61da8476984f18fc13883ae2fdb  dh-etherpad-apb          Note taking web applicationRemove all APBs:
apb remove --all
$ apb remove --all2.5.4. relist
Description
Forces service catalog to relist the provided services to match the broker.
Usage
apb relist [OPTIONS]
$ apb relist [OPTIONS]Options
| Option, Shorthand | Description | 
|---|---|
| 
									 | Show help message | 
| 
									 | Name of the ServiceBroker Kubernetes resource | 
| 
									 | Use secure connection to OAB | 
| 
									 | Specify the basic authentication user name to be used | 
| 
									 | Specify the basic authentication password to be used | 
Examples
apb relist
$ apb relist2.6. Other Commands
2.6.1. help
Description
Displays a help message.
Usage
apb help
$ apb helpExamples
apb help
$ apb helpapb -h
$ apb -h