Class: Kitchen::Provisioner::PolicyfileZero

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

Overview

Policyfile + Chef Zero provisioner.

Author:

  • Daniel DeLeo <dan@chef.io>

Instance Method Summary collapse

Instance Method Details

#create_sandboxObject



86
87
88
89
90
91
92
# File 'lib/kitchen/provisioner/policyfile_zero.rb', line 86

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



80
81
82
83
# File 'lib/kitchen/provisioner/policyfile_zero.rb', line 80

def finalize_config!(*args)
  super
  banner("Using policyfile mode for chef-client")
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
# File 'lib/kitchen/provisioner/policyfile_zero.rb', line 126

def load_needed_dependencies!; end

#run_commandObject



95
96
97
98
99
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 95

def run_command
  level = config[:log_level] == :info ? :auto : config[:log_level]

  cmd = "#{sudo(config[:chef_client_path])} --local-mode"
    .tap { |str| str.insert(0, "& ") if powershell_shell? }

  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

  if config[:named_run_list]
    args << "--named-run-list #{config[:named_run_list]}"
  end

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