Sha256: 28c9fb7ad27a7f3c4f8e8c3ce66764090811bb71458ae1a9212ff312a47f3b0b

Contents?: true

Size: 1.23 KB

Versions: 71

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require 'bolt/error'

# Parses common ways of referring to targets and returns an array of Targets.
#
# > **Note:** Not available in apply block
Puppet::Functions.create_function(:get_targets) do
  # @param names A pattern or array of patterns identifying a set of targets.
  # @return A list of unique Targets resolved from any target URIs and groups.
  # @example Resolve a group
  #   get_targets('group1')
  # @example Resolve a target URI
  #   get_targets('winrm://host2:54321')
  # @example Resolve array of groups and/or target URIs
  #   get_targets(['host1', 'group1', 'winrm://host2:54321'])
  # @example Resolve string consisting of a comma-separated list of groups and/or target URIs
  #   get_targets('host1,group1,winrm://host2:54321')
  # @example Run on localhost
  #   get_targets('localhost')
  dispatch :get_targets do
    param 'Boltlib::TargetSpec', :names
    return_type 'Array[Target]'
  end

  def get_targets(names)
    inventory = Puppet.lookup(:bolt_inventory)
    # Bolt executor not expected when invoked from apply block
    executor = Puppet.lookup(:bolt_executor) { nil }
    # Send Analytics Report
    executor&.report_function_call(self.class.name)

    inventory.get_targets(names)
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
bolt-3.0.1 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-3.0.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.44.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.42.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.40.2 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.40.1 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.38.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.37.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.36.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.35.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.34.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.33.2 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.33.1 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.32.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.31.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.30.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.29.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.28.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.27.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
bolt-2.26.0 bolt-modules/boltlib/lib/puppet/functions/get_targets.rb