bolt-modules/boltlib/lib/puppet/functions/set_var.rb in bolt-1.31.1 vs bolt-modules/boltlib/lib/puppet/functions/set_var.rb in bolt-1.32.0
- old
+ new
@@ -7,17 +7,18 @@
# **NOTE:** Not available in apply block
Puppet::Functions.create_function(:set_var) do
# @param target The Target object to set the variable for. See {get_targets}.
# @param key The key for the variable.
# @param value The value of the variable.
- # @return [Undef]
+ # @return The target with the updated feature
# @example Set a variable on a target
# $target.set_var('ephemeral', true)
dispatch :set_var do
param 'Target', :target
param 'String', :key
param 'Data', :value
+ return_type 'Target'
end
def set_var(target, key, value)
unless Puppet[:tasks]
raise Puppet::ParseErrorWithIssue
@@ -26,8 +27,11 @@
inventory = Puppet.lookup(:bolt_inventory)
executor = Puppet.lookup(:bolt_executor)
executor.report_function_call(self.class.name)
- inventory.set_var(target, key, value)
+ var_hash = { key => value }
+ inventory.set_var(target, var_hash)
+
+ target
end
end