Create a Puppet job

Create a Puppet job

POST api/jobs/puppet

Orchestrate the Puppet agent to perform a job. The response will indicate that the Puppet job is scheduled to run. You can use the job ID from the response to retrieve the job status and payload.

In order to perform this action, the following conditions must be met:

  • Must have the Remote Job Execution feature turned on at the site level.
  • The user must have the following capabilities:
    • Create and Update a Puppet Run job

Request syntax

post api/jobs/puppet '{target_details}'

Request parameters

The request accepts the following data in JSON format.

ParameterTypeDescriptionRequired
hostnamesString arrayThe list of nodes on which to run the Puppet job.Dependent. Only if no node group or saved filter is provided.
node_group_nameStringThe name of the node group on which to run the Puppet job. The Puppet job will run on all nodes that are members of the node group.Dependent. Only if no hostnames or saved filter is provided.
node_group_idIntegerThe ID of the node group on which to run the Puppet job. The Puppet job will run on all nodes that are members of the node group.Dependent. Only if no hostnames or saved filter is provided.
saved_filter_nameStringThe name of the saved filter on which to run the Puppet job. The Puppet job will run on all nodes that match the saved filter.Dependent. Only if no hostnames or node group is provided.
saved_filter_idIntegerThe ID of the saved filter on which to run the Puppet job. The Puppet job will run on all nodes that match the saved filter.Dependent. Only if no hostnames or node group is provided.
actionStringThe Puppet action to start. Available options are: status, enable, disable, runonce, and last_run_summary.Yes
environmentStringThe Puppet environment to use. This parameter is specified when the runonce action is used.Only if the runonce action is used.
noopBooleanWhether or not to run Puppet as a dry-run. If true, the --noop flag is passed to Puppet and the daemon runs in a no-op or dry-run mode. This is useful for seeing what changes Puppet will make without actually executing the changes.No
reasonStringThe reason to disable Puppet. This parameter is only specified when the disable action is used.Only if the disable action is used.

Response syntax

When the hostnames request parameter is used, the following response syntax is received.

{
    "id": integer,
    "type": "Puppet",
    "status": "string",
    "message": "string",
    "trigged_by": "string",
    "success_nodes_count": integer,
    "failed_nodes_count": integer,
    "total_nodes_count": integer,
    "parameters": {
        "action": "string",
        "hostnames": [
            "string",
            "string"
        ]
    },
    "payload": "string",
    "time_started": "timestamp"
}

When the node group or saved filter request parameters are used, the following response syntax is received.

{
    "id": integer,
    "type": "Puppet",
    "status": "string",
    "message": "string",
    "trigged_by": "string",
    "success_nodes_count": integer,
    "failed_nodes_count": integer,
    "total_nodes_count": integer,
    "parameters": {
        "action": "string",
        "node_group_name": "string",
        "node_group_id": integer,
        "saved_filter_name": "string",
        "saved_filter_id": integer
    },
    "payload": "string",
    "time_started": "timestamp"
}

Response parameters

If the action is successful, an HTTP 200 response is returned. The following data is returned in JSON format.

FieldTypeDescription
idIntegerThe ID of the Puppet job.
typeStringThe type of job. For Puppet jobs, it is Puppet.
statusStringThe status of the job.
messageStringThis field is reserved for internal use.
trigged_byStringThe username of the person who initiated the job.
success_nodes_countIntegerThe number of nodes that returned a successful response.
failed_nodes_countIntegerThe number of nodes that returned a failed response.
total_nodes_countIntegerThe total number of nodes the job ran on.
parametersStringThe request parameters indicating the hostnames, node groups, or saved filters the Puppet job ran on.
payloadStringThe payload for the job.
time_startedTimestampThe timestamp indicating when the job started. The timestamp is given in ISO 8601 UTC datetime format.

The following data is returned if you include the payload.

ParameterDescription
total_resourcesThe total number of resources in the Puppet catalog.
out_of_sync_resourcesThe number of resources the Puppet agent detects changes on and acts upon. This value is a sum of both successful and failed changes.
failed_resourcesThe number of resources the Puppet agent detected a change on but failed to apply the change.
changed_resourcesThe number of resources the Puppet agent detected a change on and successfully applied the change.
corrected_resourcesThe number of resources that were corrected during the Puppet run.
skipped_resourcesThe number of resources that were skipped during the Puppet run.
total_timeThe amount of time, in seconds, that the Puppet job ran for.
config_retrieval_timeThe amount of time, in seconds, that Puppet took to retrieve the configuration.
since_lastrunThe amount of time, in seconds, that has elapsed since the last Puppet run completed.

Errors

The following are common errors returned by this API. For a list of additional common errors, see Common errors.

CodeMessageCause
400The job target is missing, please specify targets using the fields: hostnames, node_group_id, node_group_name, saved_filter_id or saved_filter_name.The request didn't include a target. Edit the request and include at least one target and try again.
400Please use only one target parameterThe request included multiple target parameters. Verify the request only specifies a single target and try again.
400Hostnames <hostnames> does not exist.The request specified a hostname that doesn't exist. Verify the request and try again.
400The node group name <node_group_name> does not exist.The request specified a node group name that doesn't exist. Verify the request and try again.
400Node group id <node_group_id> does not exist.The request specified a node group ID that doesn't exist. Verify the request and try again.
400Filter title <filter_name> does not exist.The request specified a saved filter name that doesn't exist. Verify the request and try again.
400Filter id <filter_id> does not exist.The request specified a saved filter ID that doesn't exist. Verify the request and try again.
403Remote Job Execution feature disabled!The Remote Job Execution feature is turned off at the site level. Have an Administrator turn it on and try again.
422An unfinished job was found with the same type, parameters and username (id: <existent job id>).A similar job is already running. Wait until that job completes before starting a new job.
422Reason: Can't be blank.The reason parameter is required when starting a job with the disable action. Specify a reason and try again.
500An unexpected error happened. Please contact support!An unexpected error, such as an internal error occurred. Contact support.

Examples

Use the following links to view examples for each of the available Puppet Job actions.