Ansible job templates
A job template names a playbook in a git project, an inventory and the credentials it runs with, as in AWX. A launch runs it with the plain ansible-playbook command on a runner in your network, in a clean folder, and the credentials' values stay in the vault until that job starts.
How a launch runs
A launch from the dashboard, the API or the CLI is a run of the built-in workflow shiftlabs-ansible, tagged template=<name>, whose one Ansible step runs one job on a runner. step.ansible in your own workflow runs the same job in that workflow's run.
- The built-in workflow
shiftlabs-ansibleis fixed and is labelled Built-in on the Workflows screen. It can't be deployed, deleted, rolled back, drafted or released: those answer403 {"error": "shiftlabs-ansible is built in and can't be changed"}. It doesn't count toward your plan's workflow limit. Its launches count as runs, and their jobs as runner commands, under your plan's usual run caps and longest command. - One job, a clean folder
The job runs on a runner of the template's pool, in a new folder that is removed afterwards. It checks out the project's commit with its submodules into that folder, then runs
ansible-playbookfrom the checkout, so the repository'sansible.cfgand relative paths behave as on your laptop. Each launch has its own Ansible temp folder and SSH control sockets, and its own ssh-agent for its keys. - The plain CLI
The job runs
ansible-playbookitself, not ansible-runner, with the arguments AWX would pass. The result lists them incommand, so you can run the same command by hand. - Never retried
A playbook that fails stays failed. Running it again is a new launch, which reads the template, the project's ref and the credentials again.
- Pause
shiftlabs-ansibleas any workflow to hold new launches: each launch then answers202with"held": true, and resuming starts them in order. See Pause a workflow. - Cancel a launch as any run. The runner stops
ansible-playbookwithSIGTERM, thenSIGKILL10 seconds later. Hosts may be left half changed, as in AWX. - A runner that dies during a launch fails it after a minute. A launch no runner takes within 1 hour fails, as any command does. Runners with an activities file never take launches.
The records
Four kinds of record make up a launch, each kept by name: lowercase letters, digits and -, up to 63 characters. Each may carry awxId, the id it had in AWX, unique within its kind.
- Credentials
How ansible logs in: a Machine, Source Control, Vault or Network credential. It holds plain inputs such as
username, and refers to vault secrets for its passwords and keys. See Credentials. - Projects
A git repository and the ref to check out.
- Inventories
Static hosts and groups, and sources ansible reads at launch.
- Templates
The playbook, the project, the inventory and credentials it runs with, and the options a launch may change.
- Viewers can read records. Developers can save and delete projects, inventories and templates. Credentials, and the values of their fields, need an admin.
- A record must name records that exist: a template its project, inventory and credentials, an inventory the projects of its git sources, a project its Source Control credential. Saving one that doesn't answers
400naming what is missing. - A record others name can't be deleted: the delete answers
409withreferrers, each{kind, name}. A credential others name can't change its kind either. - API keys limited to some workflows can't read or change records.
Projects
urlThe git repository:
https://…,ssh://…oruser@host:path, up to 2,048 characters. A user name or password in the URL is refused: put them on the project's credential.refThe branch, tag or full commit hash a launch checks out.
credentialA Source Control credential for the checkout, or
nullfor a public repository.allowRefOverrideLets a template or a launch check out another ref.
falseby default.profileThe runner image profile launches of its templates ask for, or
null. See Which runner.
- A branch or tag is fetched with depth 1, and so is a commit hash where the git server allows it. Otherwise the job fetches every branch and tag to find the commit. A playbook that reads git history sees that shallow clone.
- The checkout trusts the git server's SSH host key the first time it sees it, as AWX does, and keeps that key inside the job's folder only.
Inventories
staticHosts and groups as ansible's YAML inventory, written as JSON: each group's
hosts, each with its vars, the group'svarsand itschildren.nullfor none.sourcesUp to 10 sources ansible reads when the launch starts:
{ "kind": "git", "project", "path" }, a file or folder in a project, or{ "kind": "plugin", "file", "config", "env" }, an inventory plugin's config.
- Sources run on the runner at launch: nothing is synced to Shift Labs. The static hosts come first, then each source in order, each as one
--inventoryargument. - A git source in the template's project reads the launch's checkout. A source in another project gets a checkout of that project's
ref. - A plugin source's
fileis the config's file name, such asaws_ec2.yml, andconfigits text, such asplugin: amazon.aws.aws_ec2. ansible loads it through itsautoplugin, so the plugin and its Python libraries must be in the runner's image. envsets variables for the plugin, each text or{ "secret": "NAME" }, a readable secret. Names starting withSHIFTLABS_orANSIBLE_NET_, and the variables the launch sets itself, are refused.
Templates
project·refThe project, and a ref to check out instead of the project's.
refneeds the project'sallowRefOverride;nullchecks out the project's.playbookThe playbook's path in the project, such as
playbooks/site.yml: no leading/or-, and no.or..parts.inventoryThe inventory's name.
credentialsUp to 20 credential names: at most one Machine and one Network credential, and Vault credentials with different vault IDs. Source Control credentials belong to projects.
extraVarsUp to 50 entries passed as
--extra-vars, in order. See Extra vars.limit·tags·skipTagsOne line each, up to 1,024 characters, or
null.verbosity·forks-vrepeated 0 to 5 times, and 0 to 200 forks, 0 for ansible's default.timeoutSecondsAWX's job timeout: how long the whole job may run, checkout included. 0 or
nullfor your plan's longest command. This is not ansible's connection timeout, which stays withansible.cfgoransible_ssh_timeout.become·check·diff--become,--checkand--diff.falseby default.askOnLaunchThe fields a launch may set:
ref,inventory,credentials,extraVars,limit,tags,skipTags,verbosity,forks,timeout,checkanddiff.surveyAWX's survey:
{ "enabled", "spec" }, wherespecis AWX'ssurvey_spec,{ "name", "description", "spec" }with its questions. It is checked when the template is written, as AWX checks one: each question needs itsquestion_name,variable,typeandrequired, and a choice question itschoices. Adefaultmust match its question's type, and a choice question'sdefaultmust be one of its choices. Adefaultoutside the question'sminormaxis kept but never used, as in AWX. A password question can't have adefault: leave it empty, or$encrypted$as AWX shows one, so that a template never holds a password. A launch answers it insurvey: see Survey answers. A template saved before these checks with a survey they refuse can't launch until it is saved again: its launch answers400naming the problem.runnerThe runner pool. Default
"default".titleA display name, such as the template's name in AWX.
Credentials
A credential holds plain inputs, and for each secret field the name of the vault secret that holds its value, or null until it has one. Values never appear in a record, in the API's answers or in the job's script.
| Kind | Inputs | Secret fields | Passed to ansible as |
|---|---|---|---|
machine Machine | username (default root), becomeMethod, becomeUsername | sshKeyData, sshPublicKeyData, sshKeyUnlock, password, becomePassword | The key, with its certificate, in the launch's ssh-agent, unlocked with sshKeyUnlock; --connection-password-file, --become-password-file, --user, --become-method, --become-user |
scm Source Control | username | sshKeyData, sshKeyUnlock, password | The checkout only: the key in the agent, removed before the playbook starts, or the user name and password for the project's https host |
vault Vault | vaultId | vaultPassword, required | --vault-id=<vaultId>@<file>, or --vault-password-file without a vault ID |
network Network | username, authorize | password, sshKeyData, authorizePassword (needs authorize) | AWX's variables: ANSIBLE_NET_USERNAME, ANSIBLE_NET_PASSWORD, ANSIBLE_NET_SSH_KEYFILE, ANSIBLE_NET_AUTHORIZE, ANSIBLE_NET_AUTH_PASS |
curl -X PUT https://api.shiftlabs.org/v1/ansible/credentials/prod-ssh \
-H "authorization: Bearer $SHIFTLABS_API_KEY" -H "content-type: application/json" \
-d '{"kind": "machine", "inputs": {"username": "deploy", "becomeMethod": "sudo"},
"secrets": {"sshKeyData": null, "becomePassword": null}, "workflows": ["patch-web"]}'
# The value from standard input, never the command line.
shiftlabs ansible credential set prod-ssh sshKeyData < deploy_key
shiftlabs ansible credential set prod-ssh becomePassword --secret PROD_BECOME_PASSWORD
curl https://api.shiftlabs.org/v1/ansible/credentials/prod-ssh -H "authorization: Bearer $SHIFTLABS_API_KEY"
# {"name": "prod-ssh", "id": "a1b2c3d4", "kind": "machine", …, "secrets": {
# "sshKeyData": {"set": true, "secret": "ANSIBLE_A1B2C3D4_SSHKEYDATA", "unmasked": null},
# "becomePassword": {"set": true, "secret": "PROD_BECOME_PASSWORD", "unmasked": null}}}
- Set a value
PUT /v1/ansible/credentials/:name/fields/:field {"value"}, orshiftlabs ansible credential set <credential> <field>, which reads the value from standard input. The vault keeps it as the credential's own secret,ANSIBLE_<ID>_<FIELD>, which only Ansible jobs can read. - Use an existing secret
{"secret": "NAME"}, or--secret NAME, points the field at a readable secret you already have. - Clear a value
DELETE /v1/ansible/credentials/:name/fields/:field, orshiftlabs ansible credential clear. The field then needs a value again. - Read it
GET /v1/ansible/credentials/:nameshows each field the credential declares as{set, secret, unmasked}: whether it has a value, the secret that holds it, and who accepted a short value. Never the value. A field the credential'ssecretsleaves out isn't the credential's, and launches never ask for it.
- ansible strips spaces and line ends from both ends of password files, so a password can't start or end with a space.
- A Network credential takes no
sshKeyUnlock: ansible reads a Network key from a file, not through the agent, so the key must have no passphrase, as in AWX. - A launch whose credentials lack a value answers
409naming each credential and field: see Refusals. - A secret a field names must be readable by the workflow that launches, and a launch rereads values when its job starts, so a rotated value is used at once.
Short values
The runner replaces secret values of 8 bytes or more with [redacted] in output. A shorter value, such as a 6-character enable password, can't be masked: masking it would mangle unrelated output.
A value under 8 bytes once spaces and line ends at both ends are trimmed can be used only after an admin accepts the risk, field by field, when setting it. That value then shows in clear in the run's logs and in the result's output wherever a playbook prints it, for example a debug of ansible_become_password. ansible itself doesn't print it: it gets the value from a file.
- Without acceptance, setting a short value answers
422:credential <name> field <field>: values under 8 bytes can't be masked in logs; set acceptUnmasked to accept that a playbook that prints it shows it in clear. - Accept it with
{"value": "…", "acceptUnmasked": true}, orshiftlabs ansible credential set <credential> <field> --accept-unmasked. The acceptance belongs to that value: setting another value, or clearing the field, ends it. GETshows who accepted it and when, in the field'sunmasked: {acceptedBy, acceptedAt}, so any viewer can see which credentials carry unmasked values.- Each launch that uses it prints one line before the playbook, naming the field, never the value:
shiftlabs-ansible: credential edge-net field authorizePassword is under 8 bytes and isn't masked in this run's logs (accepted by <who>, <date>). - A field bound to an existing secret whose trimmed value is under 8 bytes refuses the launch, since nobody accepted it: set the value on the field with
acceptUnmaskedinstead.PUT /v1/secretsdoesn't take such a value, so only a secret set before it measured values trimmed can hold one. - Values are measured again when the launch's job is sent to a runner, since it can wait for one, while a change window is closed say. A value made short in the meantime fails the launch, naming the field and its secret, and one set short and accepted in the meantime gets its line.
- An accepted short value reaches Ansible jobs only: no workflow code can read it, and it can't be given hosts or used for signing.
Who can use a credential
A credential's values reach shiftlabs-ansible's jobs, and the jobs of the workflows the credential lists in workflows. A workflow that calls step.ansible must be listed by every credential the launch uses, its projects' included.
- Any other workflow is refused before a job starts, naming the credential and the workflow:
credential edge-net doesn't allow workflow nightly-backup; add it to the credential's workflows. - Changing
workflowschanges at once who can read the credential's own secrets. A secret bound with{"secret": "NAME"}keeps its own scope. - Jobs on one runner share its user and home folder, so running one job at a time doesn't keep credentials apart: files a playbook leaves in the home folder, such as
~/.ansible.cfg, or~/.ssh/configwhere~/.sshis writable, change later jobs. See What a runner runs. - Run launches that carry credentials on dedicated runners, in a pool of their own, with a token limited to
shiftlabs-ansibleand the workflows their credentials list.
Apply and export
Keep the records in a file and apply it, as with AWX's configuration as code.
{
"credentials": [
{ "name": "gh-deploy", "kind": "scm", "inputs": {}, "secrets": { "sshKeyData": null }, "workflows": ["patch-web"] },
{ "name": "prod-ssh", "kind": "machine", "inputs": { "username": "deploy", "becomeMethod": "sudo" },
"secrets": { "sshKeyData": null, "becomePassword": null }, "workflows": ["patch-web"] }
],
"projects": [
{ "name": "infra", "url": "git@github.com:acme/infra.git", "ref": "main", "credential": "gh-deploy",
"allowRefOverride": true, "profile": null }
],
"inventories": [
{ "name": "prod", "static": null, "sources": [{ "kind": "git", "project": "infra", "path": "inventories/prod" }] }
],
"templates": [
{ "name": "patch-linux", "project": "infra", "playbook": "playbooks/patch.yml", "inventory": "prod",
"credentials": ["prod-ssh"], "extraVars": [{ "arg": "env=prod" }], "become": true,
"askOnLaunch": ["limit", "extraVars", "check", "diff"] }
]
}
shiftlabs ansible apply ansible.json
shiftlabs ansible export --output ansible.json
applysaves credentials, then projects, inventories and templates, each with its ownPUT, so a record only names records saved before it. It stops at the first refusal, naming the record. Records the file leaves out are kept.exportwrites every record in that shape. Each credential's fields arenull, and itsidis left out.- Applying a credential with a field
nullkeeps that field's value, so applying an exported file again keeps every value. A field left out ofsecretsis dropped from the credential, and a value set on it is deleted. shiftlabs ansible list <kind>,get <kind> <name>anddelete <kind> <name>work on one record. See the CLI reference.
Import from AWX
Import AWX's credentials, projects, inventories, job templates, workflow job templates and their schedules from an awx export file or the AWX API. The report also lists the roles of users and teams. A preview shows what the import would write and what it can't take. Importing writes exactly that preview, all at once.
awx export > awx.json
shiftlabs ansible import awx awx.json --dry-run
shiftlabs ansible import awx awx.json
# From a machine that can reach a private AWX:
shiftlabs ansible import awx --url https://awx.internal --token-stdin --dry-run < awx-token.txt
- Preview
POST /v1/ansible/imports/awx {"source": {"kind": "file", "export": …}, "dryRun": true}answers the report and writes nothing. ItsplanDigestnames the preview. - AWX URL (
source.url)To read a public AWX, send
{"source":{"kind":"api","url":"https://awx.example.com","token":"…"},"dryRun":true}. Use an HTTPS origin on port 443 that the Shift Labs API can reach. For a private AWX, run the CLI inside its network with--urland--token-stdin: only the export goes to Shift Labs, not the token. CLI versions through 0.6.0 take a file instead. Both paths match objects by natural key (such as name and organization), not by numeric ID. Renaming an object in AWX makes a new record; the old record stays. - Selection and limits
Set
source.select.jobTemplatesorsource.select.workflowJobTemplatesto a list of template names, or repeat--select-job-templateor--select-workflow-job-templatein the CLI. The API reads up to 512 AWX pages per request, including related objects; the CLI can read 4,096. If the budget won't cover the read, nothing is imported. Selecting fewer templates reduces their dependency reads, but even one template needs the user and team role lists to find grants. If those lists alone exceed the API budget, use the CLI. If they exceed the CLI budget too, import anawx exportfile. - Import
The same
sourcewith the preview'splanDigestin place ofdryRunwrites every record of the preview in one transaction: all of them, or none. If anything the preview read has changed, such as a credential saved since or a different file, it answers409 {"error": "the workspace changed since the preview; preview again"}and writes nothing. - The report
imported, each record with itsaction:created,updatedorunchanged, and a note on a record whose variables it stores differently.needsInput, what you must still give, such as each secret's value, which AWX never exports.notMapped, what Shift Labs can't take, and why.previous, records an earlier import brought that the file no longer has; they stay.foundcounts the file's job templates and workflow job templates.warnings, anything else to know.GET /v1/ansible/imports/awx/:idreads the report of any of the last 20 imports.
- Importing, and its preview, need an admin: an import writes credentials.
- This release imports Machine, Source Control, Vault and Network credentials, git projects, inventories with their hosts, groups and variables and their git and inventory plugin sources, job templates with their surveys and schedules, workflow job templates as workflows, and each host as a target. Users and teams are reported, never made members.
- Each enabled host of an imported inventory also becomes a target of type
host, named as in AWX, in each group that lists it. A target is in at most 32 groups, each up to 64 characters: the report notes any group it leaves out. The host's variables stay in the inventory. The target's id is the host's name; when another target has it, or a host of another inventory shares it, the import adds 4 characters, such asweb1.example.com-3f2a. - Importing again updates a host's target in place when AWX changed the host: its type, name and groups. Its attributes and
haGroupare always kept. A target stays when its host is disabled or gone from an inventory the file has;previouslists it. A file without the inventory, such as one ofawx export --inventory Stage, says nothing of its hosts. - An import makes at most 10,000 targets, the first hosts by name. An inventory with hosts past them still imports whole, and
needsInputcounts those hosts once for it, after the templates' rows. Export part of AWX, such asawx export --inventory Prod, and import each part. - A record is named after its AWX object, in lowercase with
-. When another record has that name, or two objects would share it, the import adds 4 characters, such asprod-ssh-3f2a: an import never writes over a record it didn't make. - Importing the same file again changes nothing. An object AWX has changed since updates its record in place. A change you made to an imported record stays until AWX changes the object. A credential's
workflows, a project'sprofile, a template'srunner, andawxIdare always kept. - A deleted imported record is forgotten: the next import makes a new one, under another name if you have made a record of that name since.
- The body may be up to 8 MiB; a larger one answers
413. Export part of AWX, such asawx export --credentials --projects, and import each part. - Export an inventory's sources together, or leave
inventory_sourcesout to keep the ones already imported. - A whole-number float in an inventory's or source's variables, such as
2.0, comes in as the integer2, and the report notes it: a record's row lists 20 such floats and counts the rest. Quote it in AWX, as"2.0", to keep the.0. A template's extra vars come in as AWX's text, so they keep it. needsInput,notMappedandpreviouslist up to 2 MiB of rows between them, in that order; a warning counts any left out. A report holds up to 7 MiB: past it,importedleaves out its last hosts' rows, a warning counts them, and their targets are imported all the same.- If the store still can't keep the report, the import answers
409and writes nothing: import part of AWX at a time. - Each secret field AWX has comes in as
null, which keeps the value you set. A field AWX no longer has is dropped, and once the import has landed its value moves to the trash, where an admin can restore it. If that move fails, the report warns, and Shift Labs retries. - Each import is in the audit log as
awx_import, with its counts and who imported it.
Imported schedules
A job template's AWX schedule becomes a schedule of shiftlabs-ansible that launches the imported template at the same times. Its prompts become the launch's fields, and its extra_data the survey's answers and extra vars. The import writes them as one release, made by whoever imported, and installs shiftlabs-ansible first if it isn't yet.
- An rrule becomes a cron only when the cron fires at exactly AWX's times, in the rrule's
TZIDor UTC, including around clock changes. Otherwise the schedule isn't imported, andnotMappedsays why. Nothing is approximated. - These map:
MINUTELYevery 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30 or 60 minutes;HOURLYevery 1, 2, 3, 4, 6, 8, 12 or 24 hours;DAILY,WEEKLY,MONTHLYandYEARLYwithINTERVAL=1. Each may haveBYMINUTE,BYHOUR,BYDAY(weekdays, no ordinals),BYMONTHDAY(1 to 31) andBYMONTH. - These don't map:
COUNT,UNTIL,EXDATE,RDATE,EXRULE,BYSETPOS,BYYEARDAY,BYWEEKNO, a negativeBYMONTHDAYsuch as-1, an ordinalBYDAYsuch as1MO, a day of the month together with a day of the week, a run at a second other than 0, aDTSTARTstill to come, and an rrule without a time zone. - A schedule that runs at a time the clocks skip, such as 02:30 on the night New York moves to summer time, isn't imported: AWX skips that run, and a cron would run it an hour later. One is imported only when that later time is a run of its own, as with an hourly schedule. A schedule that runs twice or more in the skipped hour, and not in the hour before it, isn't imported either: AWX runs one of them an hour early.
- A schedule AWX disables imports paused. An import never resumes a schedule: resume it yourself. One you paused stays paused.
- A prompt the template doesn't ask for at launch is left out, as AWX ignores it, and
notMappednotes it. An execution environment, instance groups, labels and job slicing are noted the same way. - A schedule whose
extra_dataholds a value AWX keeps encrypted, such as a survey's password, needs input and isn't imported: AWX exports$encrypted$in its place. Release it yourself, with{ "secret": "NAME" }as the answer. One whose answers the template's survey refuses needs input too. - Only a job template's or a workflow job template's schedules are imported. A project's or an inventory source's are not mapped. A schedule whose template isn't imported, or isn't in the file, needs input.
- A workflow job template's schedule starts its imported workflow, with no payload. A prompt the workflow job template asks for at launch, such as a
limit, isn't mapped: AWX passes it on to the jobs the workflow runs, and the imported workflow takes none. One it doesn't ask for is left out and noted, as AWX ignores it. - A schedule is named as a record is, and counts toward your plan's schedules and their shortest interval. Past them,
needsInputlists the last by name. - Importing again leaves an unchanged schedule as it is, with any change you released to it, and updates one AWX changed. A schedule gone from its template in AWX stays, and
previouslists it. - A release that sends
schedulesreplaces every schedule, imported or not: one it leaves out is deleted, and the next import makes it again.
Imported workflows
A workflow job template becomes a TypeScript workflow that runs its nodes as AWX does, with runAwxWorkflow. Each job template node is a step.ansible launch of the imported template, named by the node's AWX identifier, with the node's prompts and extra_data as the launch's fields and survey answers. Each approval node is a step.waitForApproval with its name, description, timeout and approvers.
// Generated by the AWX import from the workflow job template "Nightly Patch" in "Default": the next import overwrites edits.
import { runAwxWorkflow, workflow, type AwxGraph } from "shiftlabs";
const GRAPH: AwxGraph = {
"converge": [],
"edges": {
"gate": { "always": [], "failure": [], "success": ["patch"] },
"patch": { "always": [], "failure": [], "success": [] }
},
"nodes": {
"gate": { "approvers": ["role:admin", "alice@acme.example"], "kind": "approval", "message": "Approve the nightly patch run", "name": "Patch tonight?", "timeoutMs": 31536000000 },
"patch": { "kind": "template", "prompts": { "limit": "web*" }, "template": "patch-linux" }
}
};
export default workflow(async ({ step }) => runAwxWorkflow(step, GRAPH));
- Edges
A node starts once each of its parents has finished or been skipped, if an edge to it fired:
successafter a parent that succeeded,failureafter one that failed,alwaysafter either. Otherwise it is skipped, and so are the nodes only it leads to. Nodes ready together run in parallel. - Converge
A node AWX marks
all_parents_must_convergestarts only once every parent has fired an edge to it, and is skipped as soon as one can't. - Approvals
Approved, the node succeeded. Denied or timed out, it failed, and its
failureandalwaysedges fire. - Failure
The run fails when a node failed with no
failureoralwaysedge after it, as AWX fails the workflow job then. A job that couldn't start, such as a launch refused, counts as failed: unlike AWX, which tells a job in error from one that failed, an imported workflow can't, so a converging node treats both alike.
- Importing deploys each new or changed workflow as a staged version, then its commit's release makes it current, with the imported schedules. A commit that fails changes no workflow: the staged version is never listed and goes after a day. Each deploy is checked as
PUT /v1/workflows/:workflow?stage=1checks one: a deploy refused, such as one past your plan's versions a day, or one whose answers hold a private key, answers its status and error, naming the workflow, and imports nothing. - A commit that deploys takes one of your workspace's 20 deploys a minute, however many workflows it stages, up to 50. So imports can stage up to 1,000 versions a minute, for example when two exports that differ are imported in turn, each commit staging every workflow again. Your plan's versions a day counts only new versions, so staging again a version a workflow already has doesn't use it up. Once new versions have used it up for the day, a commit that stages is refused. See Rate limits.
- A workflow whose generated source is that of one of its versions is staged at that version, with no new build or check, when the version was checked on the workspace's runtime, the default runner profile of the workflow's current version and your plan's CPU limit, as they are now. Of several such versions, the newest is staged. So importing an unchanged source again, or going back to an earlier export, builds nothing and uses up none of your plan's versions a day. The exception is a workflow the import adds: if its commit fails, the next import builds it again. Once new versions have used them up for the day, it's still refused, as any commit that stages is.
- Each credential a workflow's launches use, its templates' and their projects' and inventories' included, lists the workflow in its
workflows, so its jobs may use it. After an import, this holds for every workflow imported so far, including those the file leaves out and those it changes but doesn't deploy, as long as the import can read what their launches use. It can't for a workflow you've edited by hand so the import can't read it, when the file leaves it out or it's past the 50 workflows one import deploys: such a workflow isn't counted or added, so import it again or add it to the credential'sworkflowsyourself. An import only adds to a credential'sworkflows, and a credential lists at most 99. Already imported workflows take a credential's room first, then new ones, each by name. Past them, the preview leaves out each further new workflow, andneedsInputlists it ascredential <name> would list <n> workflows, the most is 99. Nothing is deployed for it. A change that would take already imported workflows past them, such as a template or project moved onto that credential, refuses the whole import: the preview'srefusedgives the credential, the imported workflows it doesn't list yet, and how many it would list, and the import answers409before deploying anything. The preview reads the credentials as the commit will: records the file leaves out, and your own edits to imported records, count too. A workflow you made yourself isn't added to a credential by an import. - A workflow is named as a record is, from the workflow job template's name, and counts toward your plan's workflows. Past them,
needsInputlists the last by name. Its AWX name is in the source's first line. - One import deploys at most 50 new or changed workflows. Past them,
needsInputlists the last by name: import the same file again for the rest. A changed workflow left out keeps its current version until then. - Importing again leaves an unchanged workflow as it is, with any version you deployed since. It's still added to the credentials of the launches AWX gives it, and of your version's when the import can read them: if your edits launch other templates, add it to their credentials yourself. One AWX changed is deployed again from AWX, over your edits. A workflow job template gone from a file that has
workflow_job_templatesstays, andpreviouslists it. - A workflow in the trash that an import made needs input: restore it, and importing again finds it unchanged, or purge it, and importing again makes it anew.
- These aren't mapped, and the workflow job template isn't imported:
extra_vars, or an enabled survey with questions, as AWX passes them to every job it runs; a node that updates a project, syncs an inventory source, or runs a workflow or system job template; and aninventory,limit,scm_branch,job_tagsorskip_tagsa node's template asks for at launch, as AWX passes it to that job. A node whose job template isn't imported, or that answers with a value AWX keeps encrypted, needs input. - These are noted, and the workflow imported: an
inventory,limit,scm_branch,job_tagsorskip_tagsno node's template asks for, as AWX ignores it; prompts it asks for at launch; labels; webhooks; and notifications. A node's prompt its template doesn't ask for is noted as a schedule's is. - An approval without a timeout waits 365 days, the longest a step waits, and the report notes it. Approvals that share a name get
(2),(3)and so on, in the order of their nodes' identifiers. runAwxWorkflowis in the TypeScript SDK only. A workflow's deploy includes it, and theshiftlabsnpm package's types have it from 0.6.0.
Imported roles
An import never makes anyone a member of your workspace or changes a member's role. It reads the roles AWX's users and teams hold, from a file with users and teams, and reports each with the least workspace role that covers it. Only an approval step takes AWX's people, as its approvers.
- An imported approval step names your workspace's admins, as AWX's superusers and organization admins can answer any approval, and each AWX approver of it who is a member here able to answer approvals, matched by email in any case. In AWX 24.6.1 its approvers are superusers, and users with
ApproveorAdminon the workflow job template, orApprove,AdminorWorkflow Adminon its organization, directly or through a team: a team's grants are its members' and its organization's admins'. - An AWX approver with no email, whose email no active member has, or who is a developer or viewer here, needs input, and the step leaves them out: invite them, or change their role to the one the row names, then import again. A viewer needs approver; a developer needs admin, as an approver can't deploy or launch and a developer can't answer approvals. A team holding an approval role with nobody the file lists needs input too. Each has one row, naming the first workflow job template they approve and saying whether there are others. A step names at most 20 approvers, workspace admins among them, taking members by email; a step with more has a row saying so.
- A file without both
usersandteams, such as one ofawx export --workflow_job_templates, doesn't say who approves: each approval step names admins only, andneedsInputsays so once for each workflow job template. - When a listed user or team has no role list, the preview warns you. AWX 24.6.1 marks those endpoints as deprecated; like
awx export, an API import leaves out a list when AWX marks it that way. A missing list does not mean the user or team has no grants. Compare the role report and imported approvers with AWX before you switch. - When a member a step names leaves, the step goes to admins, never to every approver.
- A member joining, leaving or changing role changes the approvers, so the next import updates the workflow. Between a preview and its import, it answers
409: preview again. - Each other role needs input, naming the least workspace role that covers everything it grants in AWX, the roles it implies included: admin for
Adminon an organization, team, credential or workflow job template, and an organization'sCredential AdminandWorkflow Admin, as the last two also answer approvals, which a developer can't; developer forExecute,Use,Ad Hoc(which impliesUse; Shift Labs runs no ad hoc commands), andAdminon a project, inventory or job template, and an organization'sProject Admin,Inventory Admin,Job Template AdminandExecute; approver forApprove; viewer forRead,Auditorand an organization'sMember, and forUpdateon a project or inventory and an organization'sNotification AdminandExecution Environment Admin, for theReadeach implies: the row notes that running an update or sync, or managing notification templates or execution environments, isn't mapped. A superuser's row names admin, and a system auditor's viewer. - A team's rows name who holds its grants: the first five users with
MemberorAdminon it, counting the rest, and its organization's admins, whose own rows name admin. Shift Labs has no teams. An approver's row names their first way to approve, counting the rest across the workflow job templates they approve. - Roles on instance groups aren't mapped.
Launch a template
Launch from the API, the CLI, a workflow with step.ansible, or the dashboard's Job templates screen, which launches a template with its own settings and its survey's answers. A field left out keeps the template's.
curl -X POST https://api.shiftlabs.org/v1/ansible/templates/patch-linux/launches \
-H "authorization: Bearer $SHIFTLABS_API_KEY" -H "content-type: application/json" \
-H "idempotency-key: patch-linux-2026-11-09" \
-d '{"limit": "web*", "extraVars": {"reboot": true}, "check": true}'
# 202 {"runId": "…", "versionHash": "…"}
shiftlabs ansible launch patch-linux --limit 'web*' --extra-vars '{"reboot": true}' --check --diff --wait
import { AnsibleError, workflow } from "shiftlabs";
export default workflow<{ hosts: string }>(async ({ payload, step }) => {
try {
const r = await step.ansible("patch web", {
template: "patch-linux",
limit: payload.hosts,
extraVars: { reboot: true },
profile: "network",
});
return { commit: r.commit };
} catch (err) {
if (err instanceof AnsibleError) return { failed: true, exitCode: err.result.exitCode };
throw err;
}
});
from shiftlabs import AnsibleError, workflow
@workflow
async def patch_web(ctx):
try:
r = await ctx.step.ansible(
"patch web",
template="patch-linux",
limit=ctx.payload["hosts"],
extra_vars={"reboot": True},
profile="network",
)
except AnsibleError as err:
return {"failed": True, "exit_code": err.result["exit_code"]}
return {"commit": r["commit"]}
ref·inventory·credentialsAnother ref, inventory, or list of credentials. A launch's
credentialsreplace the template's, and must keep one of each kind the template has, as AWX requires.extraVarsAn object of variables, passed after the template's so they win. See Extra vars.
limit·tags·skipTags·verbosity·forks·check·diffAs the template's.
nullor""clearslimit,tagsorskipTags.timeoutHow long the whole job may run, checkout included, such as
"30 minutes", or milliseconds.nulltakes your plan's longest command.profile·runnerThe runner image profile and the pool. A launch may always set these two.
surveyAnswers to the template's enabled survey, by variable. See Survey answers.
- A launch may set only the fields the template's
askOnLaunchlists, besidesprofile,runnerandsurvey. Any other is refused, naming it:template patch-linux doesn't take limit at launch: add it to askOnLaunch. AWX ignores such fields; Shift Labs refuses them so a misspelt limit can't run a play on every host. - The launch route needs a developer key. An API key limited to some workflows needs
shiftlabs-ansibleamong them. - Launch from the launch route or
step.ansible, which check the launch and keep a survey's passwords out of the run's payload. Anything else that would startshiftlabs-ansiblewith a payload of its own is refused and starts nothing.POST /v1/workflows/shiftlabs-ansible/runs, so MCP'srun_workflowtoo, a re-run of a launch with apayload, and creating a trigger for it answer400, and the dashboard offers no Run now or Create trigger for it, nor it in New trigger or a test run in its code editor; a trigger made for it before then answers its deliveries, test events and replays400, keeps no body in its log, and can't be rotated. Astep.start,step.callor agent tool call of it fails for good, naming the launch route. A re-run withoutpayloadstill works. - A release schedule can launch a template:
schedule("shiftlabs-ansible", { payload: { template: "patch-linux", … } }). A release that adds or changes one checks its payload against the template's survey, and refuses a password answer given as text: give it as{"secret": "NAME"}, naming a secret of yours. A schedule already in place, sent again unchanged or left out ofschedules, is refused only when it answers as text a question its template marks a password; otherwise the release keeps it as it is. A release's or promotion's answer and audit, a promotion request, andGET /v1/releasesandGET /v1/releases/:seqnever show a built-in schedule's survey answers given as text or itsextraVarsvalues: each reads$encrypted$. A release that sends$encrypted$back as an answer of a schedule it adds or changes is refused, so give the answers again when you resend a fetched manifest. Each tick checks it again against the template as it is then, and a tick it refuses starts nothing and records why, such astemplate patch-linux not found. Idempotency-Keyworks as for any run start, and belongs to one template: the same key within 24 hours answers that template's first launch again, withIdempotent-Replayed: true, even if a credential has lost its value since. On another template's launches it is409, as on another workflow's runs, so name keys after the template. See the API.step.ansibleruns the job in the calling workflow's run, and the workflow must be listed by the credentials it uses. A resumed run gets the stored result, never a second job.step.ansiblelaunches wait for the workflow's change windows, likestep.exec, and for the windows the step'swindownames: the job goes to a runner only while they're all open and no blackout holds. A held launch runs the template as it was when the step was called.- In Python, leave
refout to run the template's ref, which is the project's when the template sets none. TypeScript'sref: null, the project's ref in place of the template's,timeout: null, your plan's longest in place of the template's, andsurveycan't be given from Python yet.
Survey answers
A launch of a template whose survey is enabled answers its questions in survey, by variable. Answers need no askOnLaunch, and they go after the template's and the launch's extraVars, so they win, as in AWX. No string in them is templated.
curl -X POST https://api.shiftlabs.org/v1/ansible/templates/patch-linux/launches \
-H "authorization: Bearer $SHIFTLABS_API_KEY" -H "content-type: application/json" \
-d '{"survey": {"hosts": "web*", "batch": 5, "packages": ["openssl"], "become_pw": {"secret": "BECOME_PW"}}}'
- Each answer is checked as AWX checks it: the question's type, its
minandmax(characters, for text), and its choices."", and[]for a multiselect, is no answer: an optional question then takes itsdefault, and a required one is refused whatever its default. - A refused answer makes the launch answer
400withsurvey, each variable's problem, and start nothing. Asurveyfor a template whose survey isn't enabled is refused too. - A password question takes
{"secret": "NAME"}, naming a secret the launch can read, or the password as text. The launch route keeps a password given as text in the vault for that launch's run alone, and the run's payload names it in the password's place, so the password is never in the run's payload, its job or its logs. - On the dashboard, a template's launch form opens on its questions' defaults, as AWX's does, and shows each refused answer on its question. A password question is a password field: its answer goes as text in the launch's request alone, never in the page's address or the browser's storage.
- A password must be 8 bytes or more once spaces and line ends at both ends are trimmed, so the runner can mask it.
- The vault drops a launch's passwords when its run ends, or once the run's lifetime has passed. A rerun can't use them, and fails with
re-enter the survey's password answers: launch again: launch again, with the passwords. step.ansibletakes a password answer as{"secret": "NAME"}only: a workflow's step options are kept in its run's history.- A launch's
extraVarscan't set a password question's variable: the launch, orstep.ansible, is refused with400and that variable insurvey. Set it as a survey answer, which keeps it out of the run's record. - A secret can't be named
SURVEY_, 16 hex digits,_and a number: those names are kept for passwords given as text.
Which runner
- The pool is the launch's or the step's
runner, else the template's. - The image profile is the first set of: the launch's or the step's
profile; the project'sprofile; the calling workflow's defaultrunnerProfile; none, which any runner of the pool takes.
Refusals
A refused launch starts no run and no job. step.ansible throws the same refusal as an error.
| Status | When |
|---|---|
400 the request | The body has a wrong field, the template doesn't take a field at launch, or a record it names doesn't fit, such as a ref on a project without allowRefOverride |
403 workflow not listed | A workflow calling step.ansible uses a credential that doesn't list it |
404 no template | template <name> not found |
409 no value | {"error": "credential has no value", "credentials": [{name, kind, fields}], "detail": "credential prod-ssh (Machine) has no value for sshKeyData"}, also when a field names a secret the launch can't read |
409 short value | credential value under 8 bytes: a bound secret under 8 bytes nobody accepted |
409 secret | secret can't be read: a secret an extra var or inventory source names is missing, not readable, or out of the workflow's scope |
400 survey answers | {"error": "invalid survey answers", "survey": {"hosts": "hosts needs an answer"}, "detail": "hosts needs an answer"}: an answer the survey refuses. See Survey answers |
409 passwords gone | re-enter the survey's password answers: launch again: a rerun, once the launch's run has ended |
413 too large | The job is over a runner job's limits, naming its largest part, usually the static inventory: see Limits |
After those, the run start's own refusals apply, as for POST /v1/workflows/:workflow/runs, such as your plan's run caps.
Results and errors
step.ansible returns the job's result when ansible-playbook exits with 0. In Python it is a dict with the same keys in snake_case.
exitCodeansible-playbook's exit code, 124 when the job timed out, 127 when the runner's image lacks a tool.template·commitThe template launched, and the commit the project was checked out at, or
nullwhen the job ended before reporting one.commandansible-playbook's arguments as the job ran it. File arguments are relative to the checkout.stdout·stderr·truncated·timedOut·durationMs·runnerAs a command's. Secret values of 8 bytes or more are replaced by
[redacted].
- Any other exit code throws
AnsibleError, anExecError, with the messageansible <name>: exited with code Noransible <name>: timed out. Itsresultholds the whole result. The launch's run fails the same way. - The last line of
stderris the job's summary, startingshiftlabs-ansible:. - Output past 2 MiB doesn't reach the run's logs, and the result keeps the last 256 KiB of each stream. See Output.
Extra vars
{ "arg": "…" }Passed as typed, as
-eon the CLI:key=value, inline JSON or YAML, or@pathto a file in the project.{ "document": "…" }A YAML or JSON document, written to a file and passed as
@file.{ "secret": "NAME" }A readable secret whose value is a YAML or JSON document, passed as
@file.
- The template's entries are passed in order, so a later one wins, as with several
-eflags. Ansible may template them, so{{ … }}in them works as on the CLI. - A launch's
extraVarscome last. Every string in them is marked!unsafe, as AWX does, so ansible never templates them: a key that may launch but not deploy can't run code on the runner through them. arganddocumententries are kept and logged in clear, and never masked. Put secrets in{ "secret" }entries, in vault-encrypted files with a Vault credential, or in credentials.- A template takes up to 50 entries, up to 20 of them documents and secrets.
Host key checking
As in AWX, a launch doesn't check target hosts' SSH host keys: the job sets ANSIBLE_HOST_KEY_CHECKING=False.
The risk: anyone who can answer for a host's address, through DNS, routing or ARP on its network, gets the connection: a Machine credential's password and become password, and whatever the playbook sends, such as rendered files and their secrets. Turn checking on where that matters.
- Turn checking on with the variable
ansible_host_key_checking: true, for example in the inventory'sallvars, a group's vars or the template's extra vars. Put the hosts' keys in the runner user's~/.ssh/known_hostsor in/etc/ssh/ssh_known_hosts, in your image or a mounted file; a host whose key is in neither is then refused. - Each launch's ssh, sftp and scp read a
known_hostsfile of the launch's own, which starts empty, then the runner user's~/.ssh/known_hostsand~/.ssh/known_hosts2as they are, plus the global/etc/ssh/ssh_known_hosts. A key they learn while connecting with checking off goes in the launch's file only and goes with the launch, so it can't make a later checked launch trust a host. ansible-core'sparamikoconnection reads the runner user's~/.ssh/known_hostsand records no key. Add the keys you trust to those files beforehand. network_cli(ansible.netcommon) always runs over libssh in a launch:ansible_network_cli_ssh_type: paramiko, wherever it's set, is overridden to libssh, because netcommon's paramiko backend accepts and records every host key whatever the host-key settings say. libssh reads~/.ssh/known_hostsin the runner user's home, the one in its passwd entry rather than$HOME, and/etc/ssh/ssh_known_hosts, never the launch's own file. With checking on it refuses an unknown or changed key, failing the task withlibssh: The authenticity of host, and it records no key: the launch turns libssh'shost_key_auto_addoff, and a repository'sansible.cfgcan't turn it back on.netconf(ncclient) checks host keys only with checking on, and records none. Python libraries that do their own SSH, such as netmiko, napalm, scrapli, ncclient and PyEZ, are outside the launch's host-key handling, as any task's own code is.- A key a task writes on purpose, with
ansible.builtin.known_hosts, orcopyortemplateto~/.ssh/known_hosts, goes in the runner user's file, as on the CLI, so the rest of that launch trusts it, and so does every later launch. A key a task removes there, as for a rebuilt host, is no longer trusted, except one the launch's own ssh learned: that one is in the launch's file, so the rest of that launch still trusts it. The launch's log then warns that the file changed, naming it, and nothing changes it back. Launches running at the same time read the same file, so a key one of them writes there is trusted by the others at once. - To read its own file first, a launch runs ssh, sftp and scp through wrappers of its own, which it names with the extra vars
ansible_ssh_executable,ansible_sftp_executableandansible_scp_executable, passed after all others, and puts first on ansible-playbook'sPATH, so a baresshin aProxyCommandruns one too. Anssh_executableset in the repository, the inventory or the playbook is overridden, and so is aUserKnownHostsFilein ssh arguments or~/.ssh/config. - The wrappers run ssh with an ssh config of the launch's own (
-F), which includes~/.ssh/configand then/etc/ssh/ssh_config, so your settings there still apply, and aProxyJumphop reads it too. Another-F, in ssh arguments such asansible_ssh_common_args, fails the connection with a message naming it: set those options in~/.ssh/config, in/etc/ssh/ssh_configor with-o. - An ssh named by its full path, such as
/usr/bin/sshin aProxyCommandin ssh arguments or in~/.ssh/config, isn't wrapped: with checking off, it adds the host's key to the runner user's~/.ssh/known_hostswhere that is writable, and so does a task given that file's full path, such as/home/runner/.ssh/known_hosts, with the same warning. In the runner image,~/.sshis read-only, so nothing is added, and a task that writes there fails, as on the CLI. On a runner of your own, make it read-only too: see SSH host keys. host_key_checking = Truein the repository'sansible.cfgdoesn't turn it on: the job's environment outranksansible.cfg. Only the variable does.
The runner's image
The published image has everything a launch needs. Your own image needs:
git, andansible-playbookfrom ansible-core 2.12 or later. A Machine credential'spasswordneeds ansible-core 2.19 or later, orsshpass.ssh-agentandssh-add, from an OpenSSH client, when a Machine or Source Control credential has an SSH key.- Each launch checks first, and a missing tool ends it with exit code 127 and a line that names it, such as
shiftlabs-ansible: this runner's image has no git. - ansible-playbook runs with the runner user's own
HOME, so~/.ansible.cfg, collections, roles and cloud credentials there are found as on the CLI, and~is that home in every module. - Windows hosts over WinRM aren't supported out of the box: the image has no pywinrm. Add it to your own image, as below.
network_clineeds ansible-pylibssh, since a launch always runs it over libssh. The network image has it; in your own image,pip install ansible-pylibssh. Without it,network_clitasks fail with "Failed to import the required Python library (ansible-pylibssh)", with host key checking off too.
FROM shiftlabsorg/runner:1.8.3@sha256:ecb8ebe8d0d0d9d7d14fe9fb08cd824d6a0f078b234c79fcb4127674cea7d30d
USER root
RUN apt-get update && apt-get install -y --no-install-recommends python3-winrm \
&& rm -rf /var/lib/apt/lists/*
USER 1000
Limits
- 1,000 records of each kind per workspace; saving one more answers
409. - A record's definition may be up to 64 KiB as JSON, an inventory's up to 512 KiB.
- A launch's job must fit a runner job's limits: 50 files and 512 KiB of file text, such as the static inventory, extra vars documents and plugin configs; a 64 KiB script; 100 environment variables. Over them, the launch answers
413naming the largest part. timeoutSecondsis at most 7 days, and a launch's timeout at most your plan's longest command.
Routes
| Route | Method | Minimum role |
|---|---|---|
/v1/ansible/:kind {" | GET | viewer |
/v1/ansible/:kind/:name the record; a credential's fields as {set, secret, unmasked}, never values | GET | viewer |
/v1/ansible/:kind/:name a project, inventory or template; PUT answers the record; DELETE {deleted}, or 409 with referrers | PUT · DELETE | developer |
/v1/ansible/credentials/:name {kind, inputs, secrets?, workflows?, awxId?}; a field null keeps its value, one left out is cleared | PUT · DELETE | admin |
/v1/ansible/credentials/:name/fields/:field {"value", "acceptUnmasked"?} or {"secret"}; DELETE clears the value | PUT · DELETE | admin |
/v1/ansible/templates/:name/launches the launch; 202 {runId, versionHash}, "held": true while paused; takes an Idempotency-Key, 409 when another template's launch holds it | POST | developer |
/v1/ansible/imports/awx previews an export (source.kind: "file") or a public AWX (source.kind: "api", url, token) with dryRun: true; with the preview's planDigest, imports it in one transaction. 409 if the plan changed; 413 over the size or page limit. | POST | admin |
/v1/ansible/imports/awx/:id the report of one of the last 20 imports | GET | viewer |