Class: PoiseBoiler::Helpers::Kitchen

Inherits:
Halite::HelperBase
  • Object
show all
Defined in:
lib/poise_boiler/helpers/kitchen.rb,
lib/poise_boiler/helpers/kitchen/provisioner.rb,
lib/poise_boiler/helpers/kitchen/policy_provisioner.rb,
lib/poise_boiler/helpers/kitchen/provisioner_helpers.rb

Overview

Helpers for Test Kitchen and .kitchen.yml configuration.

See Also:

Since:

  • 1.7.0

Defined Under Namespace

Modules: ProvisionerHelpers Classes: PolicyProvisioner, Provisioner

Constant Summary collapse

PLATFORM_ALIASES =

Shorthand names for Test Kitchen platforms.

See Also:

  • #expand_platforms

Since:

  • 1.7.0

{
  'windows' => %w{windows-2012r2},
  'windows32' => %w{windows-2008sp2},
  'ubuntu' => %w{ubuntu-14.04 ubuntu-16.04},
  'rhel' => %w{centos},
  'centos' => %w{centos-6 centos-7},
  'linux' => %w{ubuntu rhel centos},
  'unix' => %w{linux}, #, freebsd},
  'all' => %w{unix windows},
  'any' => %w{ubuntu-16.04}, # For cookbooks that don't actually use platform-specific bits.
}
DEFAULT_EC2_SUBNET_ID =

Default EC2 subnet ID when not overridden in the environment or config.

Since:

  • 1.7.0

'subnet-ca674af7'
DEFAULT_EC2_LEGACY_INSTANCES_SUBNET_ID =

Default EC2 subnet ID for previous-generation instance types.

Since:

  • 1.7.0

'subnet-1ffec232'
DEFAULT_EC2_SECURITY_GROUP_ID =

Default EC2 security group when not overridden in the environment or config.

Since:

  • 1.7.0

'sg-ed1ad892'

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Kitchen

Returns a new instance of Kitchen.

Since:

  • 1.7.0



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/poise_boiler/helpers/kitchen.rb', line 51

def initialize(**options)
  # Figure out the directory that contains the kitchen.yml by looking for
  # the first entry in the stack that isn't inside poise-boiler.
  options[:base] ||= if caller.find {|line| !line.start_with?(File.expand_path('../../..', __FILE__)) } =~ /^(.*?):\d+:in/
    File.expand_path('..', $1)
  else
    # ¯\_(ツ)_/¯ hope for the best.
    Dir.pwd
  end
  super(**options)
end

Instance Method Details

#chef_version ⇒ String?

The Chef version to use for Test Kitchen or nil for any version.

Returns:

  • (String, nil)

Since:

  • 1.7.0



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/poise_boiler/helpers/kitchen.rb', line 73

def chef_version
  # SPEC_BLOCK_CI is used to force non-locking behavior inside tests.
  @chef_version ||= ENV['CHEF_VERSION'] || if ENV['POISE_MASTER_BUILD']
    # We're going to install the latest nightly via Omnitruck later on.
    nil
  elsif ENV['SPEC_BLOCK_CI'] != 'true'
    # If there isn't a specific override, lock TK to use the same version of Chef as the Gemfile.
    require 'chef/version'
    Chef::VERSION.to_s
  end
end

#cookbook_name ⇒ Object

Since:

  • 1.7.0



85
86
87
# File 'lib/poise_boiler/helpers/kitchen.rb', line 85

def cookbook_name
  options[:cookbook_name] || cookbook.cookbook_name
end

#to_yaml ⇒ String

Generate YAML text for inclusion in a config file.

Returns:

  • (String)

Since:

  • 1.7.0



66
67
68
# File 'lib/poise_boiler/helpers/kitchen.rb', line 66

def to_yaml
  kitchen_config.to_yaml.gsub(/---[ \n]/, '')
end