Skip to content

Overview

Recipes are the core of grlx functionality, providing a structured way for developers to deploy actions to sprouts. Recipes are a collection of ingredients which can be executed against a sprout. Recipes must be placed on the farmer at /srv/grlx/recipes/prod (with support for other non-prod environments in the future). Furthermore, recipes can utilize Go’s builtin templating engine to provide dynamic functionality for deployment. Below is a simple example of the makeup of a recipe.

include:
  - .super-sprout-steps
steps:
{{ if eq (props hostname) super-sprout }}
  install super-sprout:
    file.touch:
      - name: ~/super-sprout-config
    requisites:
      - require: super-sprout-steps-completed
{{ else }}
  install normal-sprout:
    file.touch:
      - name: ~/normal-sprout-config
{{ end }}

In this example, an include is created for a super-sprout-steps.grlx file. This file would contain a list of steps with a final step grlx-sprout-steps-completed. Next we have our list of steps, bounded by Go templates. This template checks the hostname of the sprout and renders the steps to send to the farmer. In this case, if the sprout’s hostname is super-sprout, then it will render a template that looks like this:

include:
  - .super-sprout-steps
steps:
  install super-sprout:
    file.touch:
      - name: ~/super-sprout-config
    requisites:
      - require: super-sprout-steps-completed

If the hostname is anything else, the sprout will run:

include:
  - .super-sprout-steps
steps:
  install normal-sprout:
    file.touch:
      - name: ~/normal-sprout-config

It is important to note the requisites listed. This ensures that the step from the include (super-sprout-steps-completed) occurs before the install-super-sprout step is run.

Once you create a recipe, you can run it using grlx cook <name> -T <list of sprouts or \* for all sprouts>. In the case of the example above, I might run something like grlx cook example -T \* to run the above on all sprouts. You could also run grlx cook example -T \* --out json to get a json output of running this recipe against sprouts.