Class: Kitchen::Provisioner::PolicyfileZero

Inherits:
ChefBase
  • Object
show all
Defined in:
lib/kitchen/provisioner/policyfile_zero.rb

Overview

Policyfile + Chef Zero provisioner.

Author:

Instance Method Summary collapse

Instance Method Details

#create_sandboxObject



91
92
93
94
95
96
97
# File 'lib/kitchen/provisioner/policyfile_zero.rb', line 91

def create_sandbox
  create_sandbox_directory
  PolicyfileSandbox.new(config, sandbox_path, instance).populate
  prepare_cookbooks
  prepare_validation_pem
  prepare_client_rb
end

#finalize_config!(*args) ⇒ Object

Emit a warning that Policyfile stuff is still experimental.

(see Base#finalize_config!)



83
84
85
86
87
88
# File 'lib/kitchen/provisioner/policyfile_zero.rb', line 83

def finalize_config!(*args)
  super
  banner("Using experimental policyfile mode for chef-client")
  warn("The Policyfile feature is under active development.")
  warn("For best results, always use the latest chef-client version")
end

#load_needed_dependencies!Object

We don’t want to load Berkshelf or Librarian; Policyfile is managing dependencies, so these can only cause trouble.



126
127
# File 'lib/kitchen/provisioner/policyfile_zero.rb', line 126

def load_needed_dependencies!
end

#run_commandObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/kitchen/provisioner/policyfile_zero.rb', line 100

def run_command
  level = config[:log_level] == :info ? :auto : config[:log_level]
  chef_client_bin = sudo(config[:chef_client_path])

  cmd = "#{chef_client_bin} --local-mode"
  args = [
    "--config #{config[:root_path]}/client.rb",
    "--log_level #{level}",
    "--force-formatter",
    "--no-color"
  ]
  if config[:chef_zero_port]
    args <<  "--chef-zero-port #{config[:chef_zero_port]}"
  end
  if config[:log_file]
    args << "--logfile #{config[:log_file]}"
  end

  wrap_shell_code(
    [cmd, *args].join(" ").
    tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
  )
end