Skip to content

operationBook

The “operationBook” is used to create a list of operations to be executed, one after the other, on the various servers.

Operations can be of the following type :

  • commande
  • operation
  • operationBook

Attributes

AttributesMandatoryTypeDescription
command or operation or operationBookyes, one of the 3 possibilitiesstring
environmentnonobjectmore details in this chapter
whennonstringOverrides the predefined value in the operation if the operation to be executed is of type “operation” more details in this chapter
registernonstringCaptures the standard output of an operation in an environment variable more details in this chapter

Attribute details

command/operation/operationBook

Full operation path or shortcut (preferred): [namespace]/[Operation name] (path relative to the “OPSDirectory” without the “operations” directory)

environment

We have seen that we can pass variables from the command line (-e VAR=“test”). These required or optional variables, as specified in the manifest, can be included here. This makes it possible to set precise values for one or more operations and avoid having to manipulate environment variables with the command line. However, if you wish to override the value specified in “operationBook”, use the switch: -e [VAR to override]=“New Value”.

when

The value specified in “operationBook” overrides [the value set in the operation].(/en/operation#when).

register

When you want to split up your operations, it may be useful to have the result of one operation available for use in several subsequent operations. For practical reasons, the result may not be displayed on the standard output, using the “-q” switch (quiet mode).

This function is provided by the “register” attribute, which is found at the “operationBook” level. The value of “register” is a name representing a variable. As this is a global variable, by convention its name must be in uppercase (for easier identification in your code).

Once the operation has been executed, the designated variable takes the entire contents of the standard output as its value. This variable is added to the internal dynamic array of “RegisteredVariables” values.

This variable and its value will be injected into the prepared environment of all operations that follow it. You can therefore name this variable with the name of a required variable of a following operation.

If you wish to capture the error output as well, add the suffix :json to the variable name (e.g. MYVAR:json). In this case and only in this case, the value will dissociate the capture of standard output from error output using a JSON structure :

{ "stdout": "Contenu stdout", "stderr": "Contenu stderr" }

Please note the variable names given for the “register” method. The values of the internal “RegisteredVariables” array are injected into the prepared environment, and this can lead to serious side effects if the variable names are identical. To avoid this, I advise you to use the ‘REG’ prefix for this type of variable (example for “MYVAR”: “REGMYVAR”).

To understand how this mode works, please refer to this chapter.