As mentioned yesterday, BOSH manifests can be huge – 3000 lines of YAML for deploying Cloud Foundry into bosh-lite for example. I wanted to quickly pull out information from a manifest.
yaml2json
This little CLI will convert YAML to JSON.
go get github.com/bronze1man/yaml2json
We can pipe any BOSH deployment manifest into it and out comes JSON:
cat cf-manifest.yml yaml2json
jq
It’s now a single huge line of JSON. As introduced previously, for this we can use jq (visit the site and click Download).
$ cat cf-manifest.yml yaml2json | jq .
{
"compilation": {
"cloud_properties": {
"name": "random"
},
"network": "cf1",
"reuse_compilation_vms": true,
"workers": 6
},
"director_uuid": "c6f166bd-ddac-4f7d-9c57-d11c6ad5133b",
...
Oh this is looking very nice.
Q & A
What is the director_uuid
of the manifest?
$ cat cf-manifest.yml | yaml2json | jq -r .director_uuid
c6f166bd-ddac-4f7d-9c57-d11c6ad5133b
What releases are included in the manifest?
$ cat cf-manifest.yml | yaml2json | jq -r jq -r ".releases"
[
{
"name": "cf",
"version": 200
}
]
What are the names of the jobs?
$ cat cf-manifest.yml | yaml2json | jq -r ".jobs[].name"
ha_proxy_z1
nats_z1
nats_z2
etcd_z1
etcd_z2
...
What stemcell is being used for the first resource pool?
$ cat cf-manifest.yml | yaml2json | jq -r ".resource_pools[0].stemcell"
{
"name": "bosh-warden-boshlite-ubuntu-trusty-go_agent",
"version": 389
}
There are lots of possibilities to scan many BOSH deployment manifests quickly and easily with simple Bash scripts.