Class: Puppet::SSL::StateMachine::Wait

Inherits:
SSLState show all
Defined in:
lib/puppet/ssl/state_machine.rb

Overview

We cannot make progress, so wait if allowed to do so, or exit.

Instance Attribute Summary

Attributes inherited from SSLState

#ssl_context

Instance Method Summary collapse

Methods inherited from SSLState

#to_error

Constructor Details

#initialize(machine) ⇒ Wait


266
267
268
# File 'lib/puppet/ssl/state_machine.rb', line 266

def initialize(machine)
  super(machine, nil)
end

Instance Method Details

#next_stateObject


270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/puppet/ssl/state_machine.rb', line 270

def next_state
  time = @machine.waitforcert
  if time < 1
    puts _("Exiting now because the waitforcert setting is set to 0.")
    exit(1)
  elsif Time.now.to_i > @machine.wait_deadline
    puts _("Couldn't fetch certificate from CA server; you might still need to sign this agent's certificate (%{name}). Exiting now because the maxwaitforcert timeout has been exceeded.") % {name: Puppet[:certname] }
    exit(1)
  else
    Puppet.info(_("Will try again in %{time} seconds.") % {time: time})

    Kernel.sleep(time)

    # our ssl directory may have been cleaned while we were
    # sleeping, start over from the top
    @machine.session = Puppet.runtime['http'].create_session
    NeedCACerts.new(@machine)
  end
end