create service executable

Create a new executable service

Synopsis

Create

This command will create an executable service in torero's data store. An executable service allows you to run any arbitrary executable file (shell scripts, python scripts, etc.) through torero. The service can later be executed via torero's run command.

Before creating an executable service, you will need to create an executable-object that points to the binary/interpreter used to run your executable.

Executable Objects

Executable services require an executable-object to specify what binary or interpreter should be used to execute the service. For example, you might create an executable-object that points to /bin/bash to run shell scripts, or point to a specific binary on your system.

The --executable-object flag is required and must reference an executable-object that has been previously created in torero's data store.

Repository and File Configuration

The --repository flag specifies which repository contains your executable file.

The --filename flag specifies the name of the executable file within the repository. This file must exist in the --working-dir if specified, otherwise it should be at the root of the repository.

The --working-dir flag is optional and specifies the path to the directory where the executable file exists, relative to the root of the repository.

Argument Formatting

The --arg-format flag controls how arguments are passed to your executable at runtime. The default format is --{{.Key}} {{.Value}}, which passes arguments as command-line flags. You can customize this to match your executable's expected input format.

For example: - --arg-format "--{{.Key}} {{.Value}}" produces: --name value - --arg-format "{{.Key}}={{.Value}}" produces: name=value - --arg-format "-{{.Key}} {{.Value}}" produces: -name value

Specifying Secrets

Secrets that exist in torero's secret store can be set on an executable service via the --secret flag. The --secret flag's value consists of three parts:

  1. Name: The name of the secret in torero's secret store.
  2. Type: Type of secret to be injected.
  3. Target: The name of the environment variable to be injected into the service.

These parts are comma separated with a syntax that will resemble what is shown below: --secret name=my-secret,type=env,target=ENV_VAR_NAME

Specifiying Metadata

Environment variables can be specified using the --env flag and will be applied during runtime.

The --description flag provides a brief description of the service for documentation purposes.

The --tag flag allows you to associate metadata tags with the service for organization and categorization. Multiple tags can be specified by using the --tag flag multiple times.

torero create service executable <service-name> --executable-object <string> [flags]

Examples

Create A Simple Shell Script Service

Creates an executable service called backup-script that runs a bash script. This assumes you have previously created an executable-object called bash that points to /bin/bash.

>_ torero create service executable backup-script \
--executable-object bash

Create An Executable Service With Working Directory

Creates an executable service where the executable file exists in a subdirectory of the repository.

>_ torero create service executable network-config \
--executable-object bash \
--repository automation-repo \
--working-dir network-scripts \
--filename configure.sh

Create An Executable Service With Custom Arg Format

Creates an executable service that uses a custom argument format to pass arguments as KEY=VALUE pairs instead of the default --KEY VALUE format.

>_ torero create service executable env-setup \
--executable-object bash \
--repository scripts-repo \
--filename setup.sh \
--arg-format "{{.Key}}={{.Value}}"

Create An Executable Service With Decorator And Secrets

Creates an executable service that uses a decorator for input validation and injects a secret as an environment variable.

>_ torero create service executable api-caller \
--executable-object bash \
--repository scripts-repo \
--filename call-api.sh \
--decorator api-decorator \
--secret name=api-token,type=env,target=API_TOKEN

Create A Complex Executable Service

Creates an executable service that takes advantage of many available options including description, tags, working directory, decorator, and secrets.

>_ torero create service executable database-backup \
--executable-object bash \
--repository automation-repo \
--working-dir database-scripts \
--filename backup-db.sh \
--decorator backup-decorator \
--description "Automated database backup script" \
--tag backup \
--tag database \
--secret name=db-password,type=env,target=DB_PASSWORD

Options

      --arg-format string          The format to pass arguments into an executable at runtime (default "--{{.Key}} {{.Value}}")
      --decorator string           The name of the decorator to be associated with the service
      --description string         A brief description of the service
      --executable-object string   The name of the executable-object resource that points to a specific executable
                                   file on execution nodes
      --filename string            The name of the executable service file in the repository. This must exist in
                                   the working-dir
  -h, --help                       help for executable
      --repository string          The repository that contains the executable service
      --secret stringArray         Secret to be injected into the service at runtime
      --tag stringArray            Metadata tag(s) to associate with the service
      --working-dir string         The path to the directory where the executable file exists. The path must be
                                   relative to the root of the repository

Options inherited from parent commands

      --config string   Specify the path to the configuration file
      --raw             Displays the result of the command in its raw format
      --verbose         Enable verbose output

SEE ALSO