Configure Task-level options and error handling
masterIn a full playbook, tasks can define several optional fields to control execution flow and error recovery:
on_error: A command to execute on the local host if the task fails. Use the{SPOT_ERROR}variable to include the error message.user: The SSH user for this specific task (overrides the playbook-level user).targets: A list of host names, groups, tags, or addresses. Can be overridden via the-tCLI flag.tags: A list of tags for filtering. When using the-nflag, Spot matches the name exactly; if no match is found, it treats the value as a tag and runs all tasks with that tag.
Note: Every task must have a unique name field. Playbooks missing a name field will fail immediately.
- name: deploy-things
tags: ["deploy"]
on_error: "curl -s localhost:8080/error?msg={SPOT_ERROR}"
options: {ignore_errors: true, no_auto: true, only_on: [host1, host2]}
commands:
- name: wait
script: sleep 5s