Bolt data types

Sections

This page lists custom data types used in Bolt plans and their functions.

ApplyResult

An apply action returns an ApplyResult. An ApplyResult is part of a ResultSet object and contains information about the apply action.

You can access ApplyResult functions with dot notation, using the syntax: $apply_result.function.

The following functions are available to ApplyResult objects.

FunctionType returnedDescription
actionStringThe action performed. $apply_result.action always returns the string apply.
errorErrorAn object constructed from the _error field of the result's value.
messageStringThe _output field of the result's value.
okBooleanWhether the result was successful.
reportHashThe Puppet report from the apply action.
targetTargetThe target the result is from.
to_dataHashA serialized representation of ApplyResult.

ResourceInstance

ResourceInstance objects are used to store the observed and desired state of a target's resource and to track events for the resource. These objects do not modify or interact with a target's resources.

🧪 The ResourceInstance data type is experimental and might change in a future release. You can learn more about this data type and how to use it in the experimental features documentation.

You can access ResourceInstance functions with dot notation, using the syntax: $resource.function.

The following functions are available to ResourceInstance objects.

FunctionType returnedDescription
[]DataAccesses the state hash directly and returns the value for the specified attribute. This function does not use dot notation. Call the function directly on the ResourceInstance. For example, $resource['ensure'].
add_eventArray[Hash]Add an event for the resource.
desired_stateHashAttributes describing the desired state of the resource.
eventsArray[Hash]Events for the resource.
overwrite_desired_stateHashOverwrites the desired state of the resource.
overwrite_stateHashOverwrites the observed state of the resource.
referenceStringThe resource's reference string, e.g. File[/etc/puppetlabs]
set_desired_stateHashSets attributes describing the desired state of the resource. Performs a shallow merge with existing desired state.
set_stateHashSets attributes describing the observed state of the resource. Performs a shallow merge with existing state.
stateHashAttributes describing the observed state of the resource.
targetTargetThe resource's target.
titleStringThe resource title.
typeStringThe resource type.

Result

For each target that you execute an action on, Bolt returns a Result object and adds the Result to a ResultSet object. A Result object contains information about the action you executed on the target.

You can access Result functions with dot notation, using the syntax: $result.function.

The following functions are available to Result objects.

FunctionType returnedDescription
[]DataAccesses the value hash directly and returns the value for the key. This function does not use dot notation. Call the function directly on the Result. For example, $result[key].
actionStringThe type of result. For example, task or command.
errorErrorAn object constructed from the _error field of the result's value.
messageStringThe _output field of the result's value.
sensitiveSensitiveThe _sensitive field of the result's value, wrapped in a Sensitive object. Call unwrap() to extract the value.
okBooleanWhether the result was successful.
statusStringEither success if the result was successful or failure.
targetTargetThe target the result is from.
to_dataHashA serialized representation of Result.
valueHashThe output or return of executing on the target.

ResultSet

For each target that you execute an action on, Bolt returns a Result object and adds the Result to a ResultSet object. In the case of apply actions, Bolt returns a ResultSet with one or more ApplyResult objects.

You can access ResultSet functions with dot notation, using the syntax: $result_set.function.

The following functions are available to ResultSet objects:

FunctionParameters (if applicable)Type returnedDescription
[]Variant[Result, ApplyResult, Array[Variant[Result, ApplyResult]]]The accessed results. This function does not use dot notation. Call the function directly on the Result. For example, $result_set[0], $result_set[0, 2].
countIntegerThe number of results in the set.
emptyBooleanWhether the set is empty.
error_setResultSetThe set of failing results.
filter_set(block)blockResultSetFilters a set of results by block.
find(String $target_name)String $target_nameVariant[Result, ApplyResult]Retrieves a result for a specific target.
firstVariant[Result, ApplyResult]The first result in the set. Useful for unwrapping single results.
namesArray[String]The names of all targets that have results in the set.
okBooleanWhether all results were successful. Equivalent to $result_set.error_set.empty.
ok_setResultSetThe set of successful results.
resultsArray[Variant[Result, ApplyResult]]All results in the set.
targetsArray[Target]The list of targets that have results in the set.
to_dataArray[HashAn array of serialized representations of each result in the set.

Target

The Target object represents a target and its specific connection options.

You can access Target functions using dot notation, using the syntax: $target.function.

The following functions are available to Target objects:

FunctionType returnedDescriptionNote
configHash[String, Data]The inventory configuration for the target.This function returns the configuration set directly on the target in inventory.yaml or set in a plan using Target.new or set_config(). It does not return default configuration values or configuration set in Bolt configuration files.
factsHash[String, Data]The target's facts.This function does not look up facts for a target and only returns the facts specified in an inventory.yaml file or set on a target during a plan run. To retrieve facts for a target and set them in inventory, run the facts plan or puppetdb_fact plan.
featuresArray[String]The target's features.
hostStringThe target's hostname.
nameStringThe target's human-readable name, or its URI if a name was not given.
passwordStringThe password to use when connecting to the target.
plugin_hooksHash[String, Data]The target's plugin_hooks configuration options.
portIntegerThe target's connection port.
protocolStringThe protocol used to connect to the target.This is equivalent to the target's transport, except for targets using the remote transport. For example, a target with the URI http://example.com using the remote transport would return http for the protocol.
resourcesHash[String, ResourceInstance]The target's resources.This function does not look up resources for a target and only returns resources set on a target during a plan run.
safe_nameStringThe target's safe name. Equivalent to name if a name was given, or the target's uri with any password omitted.
target_aliasVariant[String, Array[String]]The target's aliases.
transportStringThe transport used to connect to the target.
transport_configHash[String, Data]The merged configuration for the target's transport.This function returns the merged configuration for a target's transport. This includes defaults, configuration set in inventory.yaml, configuration set in bolt-defaults.yaml, and configuration set in a plan using set_config().
uriStringThe target's URI.
userStringThe user to connect to the target.
varsHash[String, Data]The target's variables.
Puppet sites use proprietary and third-party cookies. By using our sites, you agree to our cookie policy.