Sha256: 99849cd7016cd5c61d3cf5a03bd5d8c4819663a900dbbe3801a2305d36b9a885
Contents?: true
Size: 1.91 KB
Versions: 11
Compression:
Stored size: 1.91 KB
Contents
# frozen_string_literal: true require 'bolt/util' # Wait until all targets accept connections. Puppet::Functions.create_function(:wait_until_available) do # Wait until targets are available. # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns. # @param options Additional options: 'description', 'wait_time', 'retry_interval', '_catch_errors'. # @return A list of results, one entry per target. Successful results have no value. # @example Wait for targets # wait_until_available($targets, wait_time => 300) dispatch :wait_until_available do param 'Boltlib::TargetSpec', :targets optional_param 'Hash[String[1], Any]', :options return_type 'ResultSet' end def wait_until_available(targets, options = nil) options ||= {} unless Puppet[:tasks] raise Puppet::ParseErrorWithIssue.from_issue_and_stack( Puppet::Pops::Issues::TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, operation: 'wait_until_available' ) end executor = Puppet.lookup(:bolt_executor) { nil } inventory = Puppet.lookup(:bolt_inventory) { nil } unless executor && inventory && Puppet.features.bolt? raise Puppet::ParseErrorWithIssue.from_issue_and_stack( Puppet::Pops::Issues::TASK_MISSING_BOLT, action: _('wait until targets are available') ) end executor.report_function_call('wait_until_available') # Ensure that given targets are all Target instances targets = inventory.get_targets(targets) if targets.empty? call_function('debug', "Simulating wait_until_available - no targets given") r = Bolt::ResultSet.new([]) else opts = Bolt::Util.symbolize_top_level_keys(options.reject { |k| k == '_catch_errors' }) r = executor.wait_until_available(targets, **opts) end if !r.ok && !options['_catch_errors'] raise Bolt::RunFailure.new(r, 'wait_until_available') end r end end
Version data entries
11 entries across 11 versions & 1 rubygems