Sha256: aa6b0b87ae974192024702f3c50963867d5a78cedcfebaf0a0c9261dbe77f49e
Contents?: true
Size: 1.21 KB
Versions: 10
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require 'bolt/error' # Parses common ways of referring to targets and returns an array of Targets. # # Accepts input consisting of # - a group # - a target URI # - an array of groups and/or target URIs # - a string that consists of a comma-separated list of groups and/or target URIs # # Examples of the above would be # - 'group1' # - 'host1,group1,winrm://host2:54321' # - ['host1', 'group1', 'winrm://host2:54321'] # # Returns an array of unique Targets resolved from any target URIs and groups. Puppet::Functions.create_function(:get_targets) do dispatch :get_targets do param 'Boltlib::TargetSpec', :names return_type 'Array[Target]' end def get_targets(names) unless Puppet[:tasks] raise Puppet::ParseErrorWithIssue.from_issue_and_stack( Puppet::Pops::Issues::TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, operation: 'get_targets' ) end inventory = Puppet.lookup(:bolt_inventory) { nil } unless inventory && Puppet.features.bolt? raise Puppet::ParseErrorWithIssue.from_issue_and_stack( Puppet::Pops::Issues::TASK_MISSING_BOLT, action: _('process targets through inventory') ) end inventory.get_targets(names) end end
Version data entries
10 entries across 10 versions & 1 rubygems