Class: Chef::Knife::ZeroApply

Inherits:
BootstrapSsh show all
Includes:
ZeroBase
Defined in:
lib/chef/knife/zero_apply.rb

Instance Method Summary collapse

Methods included from ZeroBase

included

Methods inherited from BootstrapSsh

#build_client_json, #ssh_command

Constructor Details

#initialize(argv = []) ⇒ ZeroApply

Returns a new instance of ZeroApply.



55
56
57
58
59
60
# File 'lib/chef/knife/zero_apply.rb', line 55

def initialize(argv = [])
  super
  self.configure_chef

  @name_args = [@name_args[0], start_chef_apply]
end

Instance Method Details

#start_chef_applyObject

rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/CyclomaticComplexity



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/chef/knife/zero_apply.rb', line 62

def start_chef_apply # rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/CyclomaticComplexity
  log_level = if @config[:verbosity] && @config[:verbosity] >= 2
                'debug'
              else
                'info'
              end

  client_path = @config[:use_sudo] || Chef::Config[:knife][:use_sudo] ? 'sudo ' : ''
  client_path = @config[:chef_client_path] ? "#{client_path}#{@config[:chef_client_path]}" : "#{client_path}chef-apply"
  s = String.new("echo #{@config[:recipe]} | #{client_path}")
  s << " -l #{log_level}"
  s << ' -s'
  s << ' --minimal-ohai' if @config[:minimal_ohai]
  s << " -j #{@config[:json_attribs]}" if @config[:json_attribs]
  s << ' --no-color' unless @config[:color]
  s << ' -W' if @config[:why_run]
  Chef::Log.info 'Remote command: ' + s
  s
end