Class: Kitchen::Provisioner::CincBase

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/provisioner/cinc_base.rb

Overview

Common implementation details for Cinc-related provisioners.

Author:

  • Cinc Project

Direct Known Subclasses

CincApply, CincInfra, CincSolo

Constant Summary collapse

CHEF_TO_CINC_KEYS =

Mapping of deprecated chef_*-prefixed config keys to their cinc_* equivalents. Lets existing kitchen.yml files using the chef_* names keep working when migrating from kitchen-omnibus-chef to kitchen-cinc.

{
  require_chef_omnibus: :require_cinc_omnibus,
  chef_omnibus_url: :cinc_omnibus_url,
  chef_omnibus_install_options: :cinc_omnibus_install_options,
  chef_omnibus_root: :cinc_omnibus_root,
  chef_client_path: :cinc_client_path,
  chef_solo_path: :cinc_solo_path,
  chef_apply_path: :cinc_apply_path,
  chef_zero_host: :cinc_zero_host,
  chef_zero_port: :cinc_zero_port,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ CincBase

Reads the local Chef::Config object (if present). We do this because we want to start bringing Cinc config and Cinc Workstation config closer together. For example, we want to configure proxy settings in 1 location instead of 3 configuration files.

Parameters:

  • config (Hash) (defaults to: {})

    initial provided configuration



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/kitchen/provisioner/cinc_base.rb', line 161

def initialize(config = {})
  # Forward any chef_*-prefixed keys to their cinc_* equivalents so that
  # the cinc_* default_config blocks see them as already-set and skip
  # their default values. The chef_* key is preserved so that
  # deprecate_config_for can emit a warning via `kitchen doctor`.
  CHEF_TO_CINC_KEYS.each do |chef_key, cinc_key|
    next unless config.key?(chef_key)
    next if config.key?(cinc_key)

    config[cinc_key] = config[chef_key]
  end

  super(config)

  if defined?(ChefConfig::WorkstationConfigLoader)
    ChefConfig::WorkstationConfigLoader.new(config[:config_path]).load
  end
  # This exports any proxy config present in the config to
  # appropriate environment variables, which Test Kitchen respects
  ChefConfig::Config.export_proxies if defined?(ChefConfig::Config.export_proxies)
end

Instance Method Details

#create_sandboxObject



184
185
186
187
188
# File 'lib/kitchen/provisioner/cinc_base.rb', line 184

def create_sandbox
  super
  sanity_check_sandbox_options!
  Cinc::CommonSandbox.new(config, sandbox_path, instance).populate
end

#init_commandObject



191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/kitchen/provisioner/cinc_base.rb', line 191

def init_command
  dirs = %w{
    cookbooks data data_bags environments roles clients
    encrypted_data_bag_secret
  }.sort.map { |dir| remote_path_join(config[:root_path], dir) }

  vars = if powershell_shell?
           init_command_vars_for_powershell(dirs)
         else
           init_command_vars_for_bourne(dirs)
         end

  prefix_command(shell_code_from_file(vars, "cinc_base_init_command"))
end

#install_commandObject



207
208
209
210
211
212
# File 'lib/kitchen/provisioner/cinc_base.rb', line 207

def install_command
  return unless config[:product_name]
  return if config[:install_strategy] == "skip"

  prefix_command(install_script_contents)
end