Method: Kitchen::Provisioner::ChefBase#check_license

Defined in:
lib/kitchen/provisioner/chef_base.rb

#check_licenseObject

Certain products that Test Kitchen uses to provision require accepting a license to use. Overwrite this method in the specific provisioner to implement this check.



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/kitchen/provisioner/chef_base.rb', line 285

def check_license
  name = license_acceptance_id
  version = product_version
  debug("Checking if we need to prompt for license acceptance on product: #{name} version: #{version}.")

  acceptor = LicenseAcceptance::Acceptor.new(logger: Kitchen.logger, provided: config[:chef_license])
  if acceptor.license_required?(name, version)
    debug("License acceptance required for #{name} version: #{version}. Prompting")
    license_id = acceptor.id_from_mixlib(name)
    begin
      acceptor.check_and_persist(license_id, version.to_s)
    rescue LicenseAcceptance::LicenseNotAcceptedError => e
      error("Cannot converge without accepting the #{e.product.pretty_name} License. Set it in your kitchen.yml or using the CHEF_LICENSE environment variable")
      raise
    end
    config[:chef_license] ||= acceptor.acceptance_value
  end
end