Skip to content

shell

Execute shell commands

Properties

Property Type Required Description
capture boolean No Capture command output (default: true). When false, output is only streamed
cmd string No Shell command to execute (required)
creates string No -
error_action string No Windows + PowerShell only — sets $ErrorActionPreference (Stop, Continue, SilentlyContinue, ...). Default: Stop. Ignored elsewhere.
interpreter string No Shell interpreter binary (any executable on PATH). Default: bash on Unix, powershell on Windows. On Windows, 'cmd' dispatches with /c, others with -Command.
run_as_admin boolean No Windows only — assert the mooncake process is elevated; fail the step if it isn't. Does not attempt UAC. Ignored on Unix.
stdin string No Input to provide to the command via stdin
unless string No -

Examples

# Inline shell with idempotency guard
- name: Initialize the swarm
  shell:
    cmd: docker swarm init --advertise-addr {{ host_ip }}
    creates: /var/lib/docker/swarm/state.json
# Multi-line script with cwd + env
- name: Build the artifact
  shell:
    cmd: |
      go mod download
      go build -o ./out/server ./cmd/server
  cwd: "{{ repo }}"
  env:
    CGO_ENABLED: "0"

Platform Support

linux, darwin, windows, freebsd

Events Emitted

  • step.stdout
  • step.stderr