class Kitchen::Pulumi::InSpecWithHosts

InSpec instances act as interfaces to the InSpec gem.

Attributes

options[RW]
profile_locations[RW]

Public Class Methods

new(options:, profile_locations:) click to toggle source

@param options [::Hash] options for execution. @param profile_locations [::Array<::String>] the locations of the

InSpec profiles which contain the controls to be executed.
# File lib/kitchen/pulumi/inspec_with_hosts.rb, line 34
def initialize(options:, profile_locations:)
  self.options = options
  self.profile_locations = profile_locations
end

Public Instance Methods

exec(system:) click to toggle source

exec executes the InSpec controls of an InSpec profile.

@raise [::Kitchen::Pulumi::Error] if the execution of the InSpec

controls fails.

@return [void]

# File lib/kitchen/pulumi/inspec_with_hosts.rb, line 16
def exec(system:)
  system.each_host do |host:|
    ::Kitchen::Pulumi::InSpec
      .new(
        options: options.merge(host: host),
        profile_locations: profile_locations,
      )
      .info(message: "#{system}: Verifying host #{host}").exec
  end
end