OtterScript & Operations
  • 23 Jan 2023
  • 2 Minutes to read
  • Dark
    Light
  • PDF

OtterScript & Operations

  • Dark
    Light
  • PDF

Article Summary

OtterScript is a Domain-Specific Language (DSL) used by Otter and BuildMaster to automate deployments, orchestration, and configuration. Although it's based on programming logic, you don't need to be a programmer to use OtterScript, which provides both a text editor and a low-code visual editor.

buildmaster-osve

Writing Scripts with OtterScript

No programming skills are required to work with OtterScript; you use the low-code visual editor to drag-and-drop the statements you need to build or deploy your applications. But if you're familiar with programming or scripting, you'll already know how much of OtterScript works.

To learn more, see the OtterScript Overview documentation. There is a Formal Specification available if you want to know precisely how OtterScript works.

What are Operations in OtterScript?

Just about everything in OtterScript is accomplished through Operations. Whether it's the Deploy-Artifact operation that is used to deploy applications to servers, or the IIS::Ensure-AppPool and IIS:Ensure-Site operations used to configure a website on a server.

BuildMaster includes many built-in operations, and you can even write your own using the Inedo SDK.

How do "Ensure" Operations Work?

When you browse operations in BuildMaster, you'll notice that many will start with Ensure-. While these operations play a key role in Otter's drift detection and configuration remediation, in BuildMaster, they effectively just mean "create or update".

For example, IIS::Ensure-AppPool will create an Application Pool in IIS if it doesn't already exist, or update the configuration of that application pool.

Create- vs. Ensure- Operations

In some cases, there will be a similar Create- and Ensure- operation; these operations behave nearly identically in BuildMaster. For example, there is both a Create-File and an Ensure-File operation.

BEST PRACTICE: Prefer Create- Operations in BuildMaster

When both types of operations are available, you should generally choose a Create- operation because the behavior will be more intuitive for deployment purposes.

The Create-File Operation creates the file you specify. If the file already exists, it will delete the old file and create a new one. Or, it will throw an error if Overwrite is not set to true.

Create-File hello-world
(
  Text: hello world!,
  Overwrite: true
)

The Ensure-File Operation will also create the file that you specify. But if the file exists, it will update only the properties you specify.

Ensure-File hello-world.txt 
(
  Text: hello world!
);

In this case, the file's modified date will not be changed, because Modified is one of the operation's parameters. That behavior may be unexpected, because the file was modified.


Was this article helpful?