Sha256: 810b5fe2ab738e2cab56599e29c2137c5b53991ec3f2fa48b6bf04bab6df04a7
Contents?: true
Size: 1002 Bytes
Versions: 30
Compression:
Stored size: 1002 Bytes
Contents
# frozen_string_literal: true require 'bolt/error' # Returns a hash of the 'vars' (variables) assigned to a target. # # Vars can be assigned through the inventory file or `set_var` function. # Plan authors can call this function on a target to get the variable hash # for that target. Puppet::Functions.create_function(:vars) do # @param target The Target object to get variables from. See {get_targets}. # @return A hash of the 'vars' (variables) assigned to a target. # @example Get vars for a target # $target.vars dispatch :vars do param 'Target', :target return_type 'Hash[String, Data]' end def vars(target) inventory = Puppet.lookup(:bolt_inventory) { nil } unless inventory raise Puppet::ParseErrorWithIssue.from_issue_and_stack( Puppet::Pops::Issues::TASK_MISSING_BOLT, action: _('get vars') ) end executor = Puppet.lookup(:bolt_executor) { nil } executor&.report_function_call('vars') inventory.vars(target) end end
Version data entries
30 entries across 30 versions & 1 rubygems