Pivotal/BOSH/CLI
BOSH | BOSH CLI | Quick Reference
CLI Quick Reference
bosh create-env
- creates a bosh environment with the director
bosh create-env <path to bosh.yml> \
- --state <path to state.json> \
- -o <path to cpi.yml> \
- -o <path to outbound-network.yml> \
- -o <path to bosh-lite.yml> \
- -o <path to bosh-lite-runc.yml> \
- -o <path to jumpbox-user.yml> \
- --var-store <path to creds.yml> \
- -v director_name="<bosh director name> \
- -v internal_ip=<internal ip for bosh director> \
- -v internal_gw=<internal ip for gateway> \
- -v internal_cidr=<internal cidr range for network> \
- -v outbound_network_name=<name for outbound nat network>
~$ bosh create-env ~/Git/workspace/bosh-deployment/bosh.yml \ --state ./state.json \ -o ~/Git/workspace/bosh-deployment/virtualbox/cpi.yml \ -o ~/Git/workspace/bosh-deployment/virtualbox/outbound-network.yml \ -o ~/Git/workspace/bosh-deployment/bosh-lite.yml \ -o ~/Git/workspace/bosh-deployment/bosh-lite-runc.yml \ -o ~/Git/workspace/bosh-deployment/uaa.yml \ -o ~/Git/workspace/bosh-deployment/credhub.yml \ -o ~/Git/workspace/bosh-deployment/jumpbox-user.yml \ --vars-store ./creds.yml \ -v director_name=bosh-lite \ -v internal_ip=192.168.50.6 \ -v internal_gw=192.168.50.1 \ -v internal_cidr=192.168.50.0/24 \ -v outbound_network_name=NatNetwork
bosh env
- shows your current environment details
bosh -e <environment alias> env
~$ bosh -e vbox env Using environment '192.168.50.6' as client 'admin' Name bosh-lite UUID f2d2eb92-5866-4c5d-8822-7c09ff0f5fc0 Version 266.4.0 (00000000) CPI warden_cpi Features compiled_package_cache: disabled config_server: enabled dns: disabled snapshots: disabled User admin Succeeded
bosh alias-env
- sets up an alias name for the environment
bosh alias-env vbox -e <director ip> --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca)
~$ bosh alias-env vbox -e 192.168.50.6 --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca) ~$ export BOSH_CLIENT=admin ~$ export BOSH_CLIENT_SECRET=`bosh int ./creds.yml --path /admin_password`
- sets up an alias name for the environment from ops man director on vsphere. You may need to ssh into the ops manager first.
bosh alias-env MY-ENV -e DIRECTOR-IP-ADDRESS --ca-cert /var/tempest/workspaces/default/root_ca_certificate
~$ bosh alias-env myenv -e 10.193.81.11 --ca-cert /var/tempest/workspaces/default/root_ca_certificate
Note: you may get an error about an invalid token if you are already logged in. log out first using bosh log-out -e alias
UPDATE: in the event that you need to remove an alias, you will have to edit your bosh config and delete it.
~$ vim ~/.bosh/config
bosh environments
- shows all the available environments
bosh environments
~$ ubuntu@opsmanager-2-2:~$ bosh environments URL Alias 10.193.81.11 env 1 environments Succeeded
bosh log-in
- log in to the director. alias is
l
bosh -e <env alias> log-in
~$ bosh -e my-env l User (): admin Password ():
NOTE: you can set the username and password as environment variables to avoid typing them in:
~$ export BOSH_CLIENT=admin ~$ export BOSH_CLIENT_SECRET=`bosh int ./creds.yml --path /admin_password`
for bosh cli, use the director credentials found in the bosh director tile
bosh log-out
- log out of the director
bosh -e <env alias> log-out
~$bosh -e vbox log-out Logged out from '192.168.50.6' Succeeded
bosh vms
- List all the virtual machines create and managed by BOSH
bosh -e env vms
~$ bosh -e myenv vms
bosh deployments
- List all of the deployments managed by BOSH
bosh -e env deployments
~$ bosh -e myenv deployments
bosh -d
- specify specific deployment and then specify a command
bosh -e env -d <deployment name> <command>
~$ bosh -e myenv -d cf-3dc74d032cbc62c7fd76 errands
bosh errands
- look up errands for a deployment
~$ bosh -e <env alias> -d <deployment id> errands
~$ bosh -e env -d p-rabbitmq-06916615265e9d7a8aaa errands Using environment '10.193.81.11' as user 'admin' (bosh.*.read, openid, bosh.*.admin, bosh.read, bosh.admin) Using deployment 'p-rabbitmq-06916615265e9d7a8aaa' Name broker-deregistrar broker-registrar delete-all-service-instances deregister-broker on-demand-broker-smoke-tests register-broker smoke-tests upgrade-all-service-instances 8 errands Succeeded
bosh run errand
- Periodically you may need to manually run an errand to troubleshoot installation problems.
bosh -e <env alias> -d <deployment id> run-errand <errand name>
~$ bosh -e env -d p-rabbitmq-06916615265e9d7a8aaa run-errand smoke-tests Using environment '10.193.81.11' as user 'admin' (bosh.*.read, openid, bosh.*.admin, bosh.read, bosh.admin) Using deployment 'p-rabbitmq-06916615265e9d7a8aaa'
bosh stemcells
- list stemcells uploaded into the director
bosh -e <env alias> stemcells
~$ ubuntu@opsmanager-2-2:~$ bosh -e env stemcells Using environment '10.193.81.11' as user 'director' (bosh.*.read, openid, bosh.*.admin, bosh.read, bosh.admin) Name Version OS CPI CID bosh-vsphere-esxi-ubuntu-trusty-go_agent 3586.24* ubuntu-trusty d074a48b3f1b0a04ef9a sc-04bc7c66-bc1f-44db-9926-980883e2deea ~ 3541.34* ubuntu-trusty d074a48b3f1b0a04ef9a sc-90dfd49a-4ec9-42a9-a3b0-ca9fc0ca611e ~ 3468.51* ubuntu-trusty d074a48b3f1b0a04ef9a sc-b97ed53b-2115-4aee-904e-f248b7c95205 ~ 3445.48* ubuntu-trusty d074a48b3f1b0a04ef9a sc-fcc00e08-d846-44de-bca6-db95e25e27e5 (*) Currently deployed 4 stemcells Succeeded
bosh upload-stemcell
- Uploads stemcell to the director. succeeds even if the stemcell is already imported.
bosh -e env upload-stemcell <location, local or http> [--fix]
~$
bosh vitals
- Allows you to see the vitals of vms within a deployment. provides alot of great output.
bosh -e <env alias> -d <deployment id> vms --vitals
~$ ubuntu@opsmanager-2-2:~$ bosh -e env -d apm-99d751ebfe1e2111535f vms --vitals Using environment '10.193.81.11' as user 'admin' (bosh.*.read, openid, bosh.*.admin, bosh.read, bosh.admin) Task 6346. Done Deployment 'apm-99d751ebfe1e2111535f' Instance Process State AZ IPs VM CID VM Type Active VM Created At Uptime Load CPU CPU CPU CPU Memory Swap System Ephemeral Persistent (1m, 5m, 15m) Total User Sys Wait Usage Usage Disk Usage Disk Usage Disk Usage elasticsearch_data/4c76547b-0b73-4933-97ec-4b33a602a320 running az1 10.193.81.73 vm-1c93762a-dd97-4776-867d-3cfe523b1541 xlarge true Thu Jul 12 21:06:21 UTC 2018 - 0.00, 0.03, 0.05 - 0.1% 0.1% 0.0% 6% (1.0 GB) 0% (0 B) 37% (30i%) 2% (0i%) 0% (0i%) elasticsearch_data/7ea1bab3-13b1-4a6c-92d3-8626abfdf4f9 running az1 10.193.81.72 vm-5824480e-e18f-418b-8bd8-a5e98d9fbd5f xlarge true Thu Jul 12 21:06:27 UTC 2018 - 0.00, 0.01, 0.00 - 0.2% 0.3% 0.1% 6% (1.0 GB) 0% (0 B) 37% (30i%) 2% (0i%) 0% (0i%) elasticsearch_data/b2cf575b-39d4-4947-a4d9-4847fd46bbc7 running az1 10.193.81.74 vm-5649acd1-137b-4bfc-8856-6ba4dfacc239 xlarge true Thu Jul 12 21:06:26 UTC 2018 - 0.00, 0.03, 0.00 - 0.2% 0.2% 0.0% 7% (1.1 GB) 0% (0 B) 37% (30i%) 2% (0i%) 0% (0i%) elasticsearch_data/fa11168a-4832-4df9-9117-2c83c029b5f0 running az1 10.193.81.75 vm-4dcfd67d-93bc-4b9f-b3c6-816d36a061b8 xlarge true Thu Jul 12 21:06:28 UTC 2018 - 0.00, 0.01, 0.00 - 0.3% 0.1% 0.0% 6% (1.0 GB) 0% (0 B) 37% (30i%) 2% (0i%) 0% (0i%) elasticsearch_master/b4cfd5f5-cece-414f-b2a5-f9f25139205e running az1 10.193.81.71 vm-d0febafe-1521-4329-a40a-949b18c7befe large true Thu Jul 12 21:06:12 UTC 2018 - 0.00, 0.00, 0.00 - 0.2% 0.1% 0.0% 6% (522 MB) 0% (0 B) 37% (30i%) 4% (0i%) 0% (0i%) mysql/1e4a4316-ae06-4553-a6b4-94181d72110b running az1 10.193.81.77 vm-ed7cebae-7e96-461e-87c0-faa425364a83 xlarge true Thu Jul 12 21:06:24 UTC 2018 - 1.01, 1.01, 1.00 - 0.2% 0.1% 0.3% 17% (2.8 GB) 0% (1.7 MB) 37% (30i%) 8% (1i%) 1% (0i%) redis/32b5861d-b94e-4a68-9247-edb704dc22d6 running az1 10.193.81.76 vm-1f8a702c-db64-491d-91d0-9e46f04f6fe7 medium true Thu Jul 12 21:06:25 UTC 2018 - 0.02, 0.03, 0.00 - 0.4% 0.4% 0.1% 3% (106 MB) 0% (0 B) 37% (30i%) 4% (0i%) 0% (0i%)
bosh manifest
Shows the manifest for all vms or a specific one. Manifests contain vm deployment information such as # of instances, ip, disk, network, availability zones, certificates, passwords, properties, etc.
See here for more manifest info
~$ bosh -e lab10 -d cf-c5624bb5858fe4afa766 manifest | less instance_groups: - azs: - first-az env: bosh: password: <redacted> instances: 0 jobs: - consumes: {} name: metron_agent properties: loggregator: tls: ....
bosh tasks
Shows the list of tasks bosh has run and in what order. Helpful for determining procedures.
~$ bosh -e lab10 tasks -r ID State Started At Last Activity At User Deployment Description Result 821 done Wed Oct 3 07:00:02 UTC 2018 Wed Oct 3 07:00:02 UTC 2018 scheduler pas-windows-26dcbbae940dda174f93 snapshot deployment snapshots of deployment 'pas-windows-26dcbbae940dda174f93' created 820 done Wed Oct 3 07:00:02 UTC 2018 Wed Oct 3 07:00:02 UTC 2018 scheduler cf-c5624bb5858fe4afa766 snapshot deployment snapshots of deployment 'cf-c5624bb5858fe4afa766' created 817 done Tue Oct 2 07:00:02 UTC 2018 Tue Oct 2 07:00:02 UTC 2018 scheduler pas-windows-26dcbbae940dda174f93 snapshot deployment snapshots of deployment 'pas-windows-26dcbbae940dda174f93' created ....
Look up specific task and grep keyword
~$ bosh -e lab10 tasks -r700 | grep "create deployment" 760 done Wed Sep 26 17:50:18 UTC 2018 Wed Sep 26 19:47:21 UTC 2018 ops_manager pas-windows-26dcbbae940dda174f93 create deployment /deployments/pas-windows-26dcbbae940dda174f93 740 done Wed Sep 26 17:04:36 UTC 2018 Wed Sep 26 17:09:43 UTC 2018 ops_manager cf-c5624bb5858fe4afa766 create deployment /deployments/cf-c5624bb5858fe4afa766 ....
bosh instances
instances are vms with a purpose. this can range from your regular long running process, such as mysql, or a temporary process, such as a smoke test.
Look up instances and their running processes
~$ bosh -e env instances --ps ... Deployment 'cf-435c6aa7c377367d89f3' Instance Process Process State AZ IPs blobstore/a1ecd523-c5eb-4363-9e7a-befd3b12a4cc - running main 10.193.82.17 ~ blobstore_nginx running - - ~ blobstore_url_signer running - - ~ bosh-dns running - - ~ bosh-dns-healthcheck running - - ~ consul_agent running - - ~ metron_agent running - - ~ route_registrar running - - compute/121ec90a-002a-4db1-91cd-953fe32d7687 - running main 10.193.82.44 ...