Skip to content

Cookbook

Ioannis Charalampidis edited this page May 10, 2016 · 6 revisions

1. Nested SSH Access

Let's say that you are trying to access a node that is inside a private network for which you need to SSH into a gateway first. You can achieve this by nesting two SSH accessors:

node:
  - name: protected-node
    host: protected1.mydomain.com
    access:
       - class: robob.access.ssh
         username: username-for-protected-node
         password/key: secret
       - class: robob.access.ssh
         host: gateway.mydomain.com
         username: username-for-gateway
         password/key: secret

2. Re-using a streamlet to another stream

Streamlets expose some metrics in the global scope. If you want to specialize them in a specific stream you can use the alias keyword to rename the metrics:

metrics:
  - name: node1.load
    title: CPU Load of node 1
  - name: node2.load
    title: CPU Load of node 2

stream:
  - app: myapp
    node: node1
    streamlets:
      - streamlet: uptime
        alias:
          load: node1.load      

  - app: myapp
    node: node2
    streamlets:
      - streamlet: uptime
        alias:
          load: node2.load      

3. Separating Configuration

In roBob is possible to load other configuration files, therefore it's possible to separate your configuration into different re-usable files. For example:

You can keep the application generic configuration in application.yaml:

environments:
   myapp.env:
     LD_LIBRARY_PATH: "/lib:/usr/lib:/usr/local/lib:/opt/special/lib"

parsers:
  - name: myapp.parser
    class: robob.parser.regex
    match:
      - "^.*?Bandwidth: (?P<bandwidth>[0-9\.]+).*$"
apps:
  - name: myapp
    binary: /path/to/binary
    env: myapp.env
    parser: myapp.parser

And you can use it in your main.yaml:

load:
  - application.yaml

...
streams:
  - app: myapp

4. Creating files before running application

Some applications might need a more complicate configuration file instead of command-line arguments. To satisfy their needs you can instruct robob to create a file before it runs the application using the files property in the application:

For example:

apps:
  - name: myapp
    binary: /path/to/binary
    args: [ "--config", "${app.files.config.path}" ]
    files:
      - name: config
        path: "/tmp/config.json"
        contents: |
          {
             "config-1": "${value}",
             "ip": "${nodes.node1.address}"
          }

The file contents, just like any property in the specs file can have macros that will be replaced at runtime. If no path argument is specified, robob will create a temporary file name for your file and store it under the ${app.files.xxxx.path} property. Optionally, you can specify an extension through suffix if your application is sensitive to it:

apps:
  - name: myapp
    binary: /path/to/binary
    args: [ "--config", "${app.files.config.path}" ]
    files:
      - name: config
        suffix: ".json"
        contents: |
          {
             "config-1": "${value}",
             "ip": "${nodes.node1.address}"
          }

Clone this wiki locally