Sha256: d6ab618046b102d740f69c98e1122c4c76db2b9a50eb52950f16582676df8ce8

Contents?: true

Size: 894 Bytes

Versions: 50

Compression:

Stored size: 894 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)
    # Bolt executor not expected when invoked from apply block
    executor = Puppet.lookup(:bolt_executor) { nil }
    executor&.report_function_call(self.class.name)

    inventory.vars(target)
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
bolt-2.15.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.14.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.13.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.12.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.11.1 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.11.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.10.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.9.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.8.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.7.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.6.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.5.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.4.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.3.1 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.3.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.2.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.1.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.0.1 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-2.0.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb
bolt-1.49.0 bolt-modules/boltlib/lib/puppet/functions/vars.rb