POST /scheduled_jobs/environment_jobs
Create an environment job to run in the future. An environment job is a deployment,
task, or plan that runs in a specific environment, such as a Puppet run on nodes in your production
environment.
Request format
When Forming orchestrator API requests to this endpoint, the
content type is application/json
. The body must be a
JSON object using these required keys:
Key | Definition |
---|---|
type
|
Enumerated value indicating the type of action you want to
schedule, either plan , task , or deploy . |
input
|
An object describing job parameters, scope, or targets. The
contents depends on the type , as
described in the input object
section, below. |
environment
|
A string specifying the name of the relevant
environment. For For
|
schedule
|
An object that uses the start_time and interval keys to describe the job's
schedule.The The "interval": { "units": "seconds", "value": 86400 } |
description
|
A string describing the job. You can supply an empty string. |
userdata
|
An object containing arbitrary key-value pairs supplied to the job, such as a support ticket number. You can supply an empty object. |
For example, this request schedules the facts
plan to
run once on the node called node1.example.com
in an
environment called my_environment
:
type_header='Content-Type: application/json' auth_header="X-Authentication: $(puppet-access show)" uri="https://$(puppet config print server):8143/orchestrator/v1/scheduled_jobs/environment_jobs" data=' { "description": "run facts plan once on node1 in my_environment", "input": { "name": "sensitive_params::scheduled_jobs_storage", "parameters": { "primary": { "value": "example.delivery.puppetlabs.net" }, "param_one": { "value": "first_value" } } }, "environment": "my_environment", "schedule": { "start_time": "2022-01-28T09:35:56-08:00", "interval": null }, "userdata": { "snow_ticket": "INC0011211" }, "type": "plan" } ' curl --insecure --header "$type_header" --header "$auth_header" --request POST "$uri" --data "$data"
The input object
The contents of the input
object depends on the job's
type (either plan
, deploy
, or task
). The keys you can use
in the input
object for each job type are described
below. Not all keys are required, but the input
object itself is a required key.
The input
object for plan
jobs can contain:
name
: String-formatted name of the plan to run.parameters
:An object containing a series of key-value pairs representing parameter inputs for the plan to use. Parameters either specify standard parameter inputs or node targets.
Standard parameter inputs are represented as a parameter name key with the value
in an object. The value
key accepts any data type as long as it is valid JSON. For
example:
"parameters": { "param_one": { "value": "some_value" } }
The plan's node targets can be declared in the targets
object. You can declare specific nodes in the value
key, much like a standard parameter input, or you
can declare a variable group of nodes by supply a PuppetDB query. To do this, you must supply a targets
object that contain your query statement in the
value
key and "type":
"query"
. For example:
"parameters": { "targets": { "type": "query", "value": "nodes[certname] { }" } }
Supplying "type": "query"
instructs the orchestrator to interpret the value
as
a PuppetDB query and pass the resulting node lists as
the parameter's value.
Here is a complete example of an input
object for a
plan
job:
"input": { "name": "sensitive_params::scheduled_jobs_storage", "parameters": { "primary": { "value": "convex-swath.delivery.puppetlabs.net" }, "targets": { "type": "query", "value": "nodes[certname] { }" } } }
You can use these keys in the input
object for
task
jobs:
Key | Description |
---|---|
name
|
String-formatted name of the task to run. |
parameters
|
An object that can be empty or contain key-value pairs
representing standard parameter inputs for the task to
use. Supply parameter name keys along with their
corresponding values in a flat structure. The "parameters": { "param_one": "some_value" } |
scope
|
An object containing exactly one key defining the nodes that
you want the task to target:
For |
targets
|
An object containing connection information for SSH/WinRM targets. |
noop
|
A Boolean specifying whether to run the task in no-op mode.
The default is false . |
concurrency
|
An integer specifying the maximum number of nodes to run at one time. The default, if unspecified, is unlimited. |
timeout
|
A positive integer specifying the maximum number of seconds
allowed for a task to execute on any one node. Task execution on
the node is forcibly ended if the timeout limit is reached. If
unspecified, this key takes the value of default-plan-timeout , which is one of the Orchestrator and pe-orchestration-services parameters. |
transport
|
A string indicating the transport method over which to run the task. |
Here is an example of a complete input
object for a task
job:
"input": { "name": "my_task", "scope": { "nodes": ["my_primary"]}, }
You can use these keys in the input
object for
deploy
jobs:
Key | Description |
---|---|
scope
|
Required. An object containing exactly one key
defining the nodes that you want the deployment to target:
For |
concurrency
|
An integer specifying the maximum number of nodes to run at one time. The default, if unspecified, is unlimited. |
debug
|
A Boolean specifying whether to use the
--debug flag on Puppet agent runs. |
enforce_environment
|
A Boolean specifying whether to force agents to run in the
specified environment. This key must be false if environment is an empty string. |
evaltrace
|
A Boolean specifying whether to use the
--evaltrace flag on Puppet agent runs. |
filetimeout
|
An integer specifying the value of the
--filetimeout flag on Puppet agent runs. |
http_connect_timeout
|
An integer specifying the value for the
--http_connect_timeout flag on Puppet agent runs. |
http_keepalive_timeout
|
An integer specifying the value for the
--http_keepalive_timeout flag on Puppet agent runs. |
http_read_timeout
|
An integer specifying the value for the
--http_read_timeout flag on Puppet agent runs. |
noop
|
A Boolean specifying whether to run the deployment in no-op
mode. The default is false . |
no_noop
|
A Boolean specifying whether to run the agent in enforcement
mode. The default is false . This key overrides
noop = true if set in the agent's
puppet.conf file. This key can't be set to
true if the noop key is also set to true in the same request. |
ordering
|
A string defining the value of the
--ordering flag on Puppet agent runs. |
skip_tags
|
A string defining the value of the
--skip_tags flag on Puppet agent runs. |
tags
|
A string defining the value of the --tags
flag on Puppet agent
runs. |
trace
|
A Boolean specifying whether to use the
--trace flag on Puppet agent runs. |
use_cached_catalog
|
A Boolean specifying whether to use the
--use_cached_catalog flag on Puppet agent runs. |
usecacheonfailure
|
A Boolean specifying whether to use the
--usecacheonfailure flag on Puppet agent runs. |
Here is an example of an input
object for a
deploy
job:
"input": { "scope": { "nodes": ["my_primary"]}, }
Response format
If the job is successfully scheduled, the server returns 200 and a JSON object containing these keys:
id
: An absolute URL that links to the newly created job. You can use it with GET /scheduled_jobs/environment_jobs/<job-id> to retrieve information about the job.name
: A stringified number identifying the newly created job.
For example:
{ "scheduled_job" : { "id" : "https://orchestrator.example.com:8143/orchestrator/v1/scheduled_jobs/environment_jobs/2", "name" : "2" } }
Error responses
If there is an error, Orchestrator API error responses provide
error information in the kind
key. Possible errors include:
Response code | Value | Definition |
---|---|---|
404 | puppetlabs.orchestrator/unknown-environment
|
The specified environment does not exist. |
400 | puppetlabs.orchestrator/empty-environment
|
The specified environment contains no nodes. |
400 | puppetlabs.orchestrator/empty-target
|
The specified scope or targets
query resolves to an empty list of nodes. |
400 | puppetlabs.orchestrator/puppetdb-error
|
The request specified a query for the scope or targets ,
and the orchestrator is unable to make a query to PuppetDB. |
400 | puppetlabs.orchestrator/query-error
|
The request specified a query for the scope or targets ,
and the query is invalid or the user submitting the request does
not have permission to run the query. |
400 | puppetlabs.orchestrator/invalid-time
|
The supplied start_time timestamp is in the past. |