Sha256: f8e5da14c0ce99a90ddc0d805d1ed983c9d44670633f56c4de27f665bed7c365

Contents?: true

Size: 1.2 KB

Versions: 19

Compression:

Stored size: 1.2 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 }
    executor&.report_function_call(self.class.name)

    inventory.get_targets(names)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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