Class: Kitchen::Terraform::InSpec::FailSlowWithHosts

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/terraform/inspec/fail_slow_with_hosts.rb

Overview

FailSlowWithHosts is the class of objects which execute InSpec against multiple hosts and raise rescued errors after all hosts have been tested.

Instance Method Summary collapse

Constructor Details

#initialize(hosts:, options:, profile_locations:) ⇒ Kitchen::Terraform::InSpec::FailSlowWithHosts

#initialize prepares a new instance of the class.

Parameters:

  • hosts (Array<::String>)

    the names or addresses of hosts on which Inspec controls will be executed.

  • options (Hash)

    options for execution.

  • profile_locations (Array<::String>)

    the locations of the InSpec profiles which contain the controls to be executed.



47
48
49
50
51
52
# File 'lib/kitchen/terraform/inspec/fail_slow_with_hosts.rb', line 47

def initialize(hosts:, options:, profile_locations:)
  self.hosts = hosts
  self.messages = []
  self.options = options
  self.profile_locations = profile_locations
end

Instance Method Details

#execself

exec executes the InSpec controls of an InSpec profile.

Returns:

  • (self)

Raises:

  • (Kitchen::TransientFailure)

    if the execution of InSpec fails.



30
31
32
33
34
35
36
37
38
# File 'lib/kitchen/terraform/inspec/fail_slow_with_hosts.rb', line 30

def exec
  hosts.each do |host|
    exec_and_continue host: host
  end

  raise ::Kitchen::TransientFailure, messages.join("\n\n") if !messages.empty?

  self
end