Actions & Workflows

Define and run actions in block.poly, override values at runtime with --set, and chain several actions into a workflow in workspace.poly.

Actions are the executable operations of a block — for example install, upgrade, backup or uninstall. Workflows chain actions from several blocks into one sequence that you start with a single command.

Defining actions

Actions live in a block's block.poly. The k8s-1.27 block, for instance, ships install, join-cluster, update-k3s, restart-k3s and uninstall; list them with polycrate action list or polycrate hub inspect ayedo/linux/k8s-1.27:<version>.

# block.poly
actions:
  - name: install
    description: "Installs the application in the cluster"
    playbook: install.yml

  - name: uninstall
    description: "Removes the application"
    playbook: uninstall.yml
    prompt:
      message: "Really remove the application?"

  - name: shell
    description: "Interactive shell"
    interactive: true
    script:
      - /bin/bash
Field Required Description
name Yes Unique name in slug format
description No Short description for action list / action inspect
playbook Either/or Ansible playbook relative to the block directory (default choice)
script Either/or List of shell commands for simple special cases
prompt.message No Confirmation prompt before execution
interactive No Starts the container with a TTY (-it)
labels No Free-form metadata
config No Action-specific defaults under action.config

playbook and script are mutually exclusive. Playbooks automatically receive the snapshot with workspace, block, action and transaction, plus ANSIBLE_INVENTORY, KUBECONFIG and K8S_AUTH_KUBECONFIG (see Ansible).

Running actions

# Run an action in the Polycrate container
polycrate run k8s install

# Skip confirmation prompts (e.g. in CI/CD)
polycrate run k8s uninstall --force

# Print the resolved snapshot without running anything
polycrate run k8s install --snapshot

# Run directly on the host without a container
polycrate run k8s install --local

# More verbose logging
polycrate --loglevel 2 run k8s install

Without arguments, polycrate run opens an interactive picker. polycrate action list and polycrate action inspect show the available actions.

Runtime overrides with --set

--set overrides individual values under action.config for a single run without touching workspace.poly or block.poly (Helm syntax):

polycrate run my-app deploy --set replicas=5 --set database.host=db.acme.internal

--set only affects action.config, not block.config, and takes the highest precedence there. Values arrive as strings; cast them in the playbook with | int or | bool where needed.

Keeping data between runs

The action container is removed after every run. Write files you want to keep into the block's artifact directory ({{ block.artifacts.path }}), see Artifacts.

Workflows

A workflow is defined in workspace.poly under workflows: and runs its steps strictly in order. Each step calls one action of one block.

# workspace.poly
name: acme-production-1
organization: acme

blocks:
  - name: cilium
    from: cargo.ayedo.cloud/ayedo/k8s/cilium:0.7.5
  - name: cert-manager
    from: cargo.ayedo.cloud/ayedo/k8s/cert-manager:0.10.2
  - name: ingress
    from: cargo.ayedo.cloud/ayedo/k8s/nginx:0.7.16
  - name: monitoring
    from: cargo.ayedo.cloud/ayedo/k8s/victoria-metrics-stack:0.24.7

workflows:
  - name: deploy-platform
    prompt:
      message: "Roll out the platform components to acme-production-1?"
    steps:
      - name: cilium
        block: cilium
        action: install
      - name: cert-manager
        block: cert-manager
        action: install
      - name: ingress
        block: ingress
        action: install
      - name: monitoring
        block: monitoring
        action: install
# Start a workflow (short or explicit form)
polycrate run deploy-platform
polycrate workflow run deploy-platform

# Pull missing blocks automatically first
polycrate workflow run deploy-platform --blocks-auto-pull

# Run a single step only
polycrate workflow run deploy-platform --step ingress

# Inspect workflows
polycrate workflow list
polycrate workflow inspect deploy-platform

Prompts and failure handling

  • prompt.message can be set on the workflow, on a step and on an action. Declining a prompt stops the workflow at that point; --force answers every prompt with yes.
  • If a step fails, the workflow stops. With allow_failure: true on the workflow, it continues and logs a warning instead. The setting applies to all steps, so reserve it for workflows that contain only non-critical steps.
  • Polycrate prints the failed step with its full output to the terminal. Reproduce it with --step <name> or directly with polycrate run <block> <action>.

Recommendations

  • Stick to the common action names (install, upgrade, uninstall, backup, restore, status) so blocks behave consistently.
  • Write idempotent playbooks: every run converges to the same target state and can safely be repeated.
  • Protect destructive actions and production workflows with prompt.message.
  • Name steps after what they do (backup-database, deploy-app), not step1.

See also