Skip to content

Extending Cloudboostr with custom ops files

Cloudboostr Ops Files

Cloudboostr uses BOSH to deploy, configure and maintain most of its components. Main concept to configure BOSH deployments is to provide operations files. You can find more details about this mechanism here: ops files. By default we use some set of operations files. You can read more detailed information about used ops files in OpsControl and Environment.

We would like to provide end users possibility to include their own ops files. To achieve that we use specific naming convention to include the priority number of ops file in its name. Thanks to that our list of ops files is statically defined and ordered. So users are able to provide extension ops file in the middle of our default ordered set.

Priority number

Ops files are sorted by priority number ascending. Which means ops files with lower number comes first. Priority number used in a filename is a four digit number with leading zeros. For example:

  • priority 0 in the file name is represented by 0000
  • priority 100 in the file name is represented by 0100
  • priority 9000 in the file name is represented by 9000

Note: There is a possibility that defualt set of ops files may change. New files can appear in the middle of previous ops files set. This can affect the order of your ops files. So please verify Release Notes before update.

Configuration

To configure extensions ops for some particular deployment you have to provide specific information in the OpsControl or Env configuration. In general those fields are:

  • extensions_bucket_name - bucket with extenstions ops files
  • extensions_$DEPLOYMENT_directory - directory inside the bucket that contains set of ops files used to customize $DEPLOYMENT (eg. $DEPLOYMENT can be bosh, dns)
  • extensions_$DEPLOYMENT_properties - name of file with ops files properties. File should be located in directory defined above (eg. $DEPLOYMENT can be bosh, dns)

So this is a three steps process:

  1. Create (or use some exiting) bucket with proper directory path inside.
  2. Put there custom ops files with priority number in the name (eg. 0100_test-ops.yaml) and optionally include some properties files.
  3. Configure proper parameters in OpsControl or Environment.

Example

In the below example we would like to show you how this can be setup. Lets use DNS deployment in Environment. We have there below ops files used:

Priority Ops name Description
DNS_OPS_FILES

Configuration is located in infrastructure/env.json:

{
    (...)
    "vars": [
        (...)
        {"name": "extensions_bucket_name",    "value": "extensions-bucket"},
        {"name": "extensions_dns_directory",  "value": "aws/env/cb-dns-deployment"},
        {"name": "extensions_dns_properties", "value": "dns.properties"}
    ]
}

So if you want to add some ops file in the middle we have to name it with proper priority, eg. 0150_test_ops.yml:

---
- type: replace
  path: /instance_groups/name=master/jobs/-
  value:
    name: pre-start-script
    release: os-conf
    properties:
      script: |-
        #!/bin/bash
        echo ((test_variable))
        exit 0

- type: replace
  path: /releases/-
  value:
    name: os-conf
    version: 20.0.0
    url: https://bosh.io/d/github.com/cloudfoundry/os-conf-release?v=20.0.0
    sha1: a60187f038d45e2886db9df82b72a9ab5fdcc49d

Now you have to place it in extensions-bucket in aws/env/cb-dns-deployment/ directory. Optionally you can provide some properties required by your ops files. In this example we use dns.properties:

test_variable: Hello World!

After our deployment we can see that dns manifest contains added script part with proper variable subsitution:

instance_groups:
- azs:
  - z1
  instances: 1
  jobs:
  - name: master
    properties:
      (...)
    release: bind9
  - name: pre-start-script
    properties:
      script: |-
        #!/bin/bash
        echo Hello World!
        exit 0
    release: os-conf
  name: env1-dns-master
(...)
name: dns
releases:
- name: bind9
  sha1: 20c490ddab0fb801ab02de29ba56ed1bc6ffedde
  stemcell:
    os: ubuntu-xenial
    version: "315.36"
  url: https://github.com/cloudfoundry-community/bind9-boshrelease/releases/download/v1.1.1/bind9-1.1.1.tgz
  version: 1.1.1
- name: os-conf
  sha1: a60187f038d45e2886db9df82b72a9ab5fdcc49d
  url: https://bosh.io/d/github.com/cloudfoundry/os-conf-release?v=20.0.0
  version: 20.0.0
(...)