Skip to content

Writing jobs

A job should be explicit, small enough to inspect, and safe to resume.

apiVersion: automax.io/v1
kind: Job
metadata:
  name: deploy-app
vars:
  app_name: myapp
targets: group:web
strategy:
  mode: rolling
  batch_size: 1
failurePolicy:
  onFailure: stop_host
  onUnreachable: stop_host
tasks:
  - id: prepare
    tags: [prepare]
    steps:
      - id: filesystem
        substeps:
          - id: create_dir
            use: fs.dir.create
            with:
              path: /opt/{{ vars.app_name }}
              mode: "0755"
              sudo: true

Use canonical plugin names

Use names returned by:

automax plugins list

Inspect parameter metadata:

automax plugins describe fs.dir.create

Keep secrets out of job files

Use {{ secrets.name }} references and resolve values from env or file providers.

Prefer idempotent plugins

Prefer:

use: fs.dir.create

over:

use: command.remote.run
with:
  command: mkdir -p /opt/myapp

Builtin plugins return changed where possible and are easier to describe, document and test.

Register outputs intentionally

- id: app_version
  use: command.remote.run
  with:
    command: cat /opt/app/VERSION
  register:
    version: stdout.trim

Registered outputs are persisted in state and can be used by later substeps.