Module: Puppet::Util::Splayer

Included in:
Agent, Application::Apply
Defined in:
lib/puppet/util/splayer.rb

Overview

Handle splay options (sleeping for a random interval before executing)

Instance Method Summary collapse

Instance Method Details

#splay(do_splay = Puppet[:splay]) ⇒ Object

Sleep when splay is enabled; else just return.



9
10
11
12
13
14
15
16
17
# File 'lib/puppet/util/splayer.rb', line 9

def splay(do_splay = Puppet[:splay])
  return unless do_splay
  return if splayed?

  time = rand(Puppet[:splaylimit] + 1)
  Puppet.info _("Sleeping for %{time} seconds (splay is enabled)") % { time: time }
  sleep(time)
  @splayed = true
end

#splayed?Boolean

Have we splayed already?

Returns:

  • (Boolean)


4
5
6
# File 'lib/puppet/util/splayer.rb', line 4

def splayed?
  !!@splayed
end