module Chef::Knife::ZeroBase

Public Class Methods

included(includer) click to toggle source
# File lib/chef/knife/zero_base.rb, line 9
def self.included(includer)
  includer.class_eval do
    deps do
      Chef::Config[:local_mode] = true
      ## deprecated CHEF-18.
      ## TODO: should implement unix domain socket forwarding (~< net-ssh 4.1.0) before will be removed.
      Chef::Config[:listen]     = true
      Chef::Config[:knife_zero] = {}
      Chef::Knife::Ssh.load_deps
    end

    ## Added by Knife-Zero
    option :why_run,
           short: '-W',
           long: '--why-run',
           description: 'Enable whyrun mode on chef-client run at remote node.',
           boolean: true

    option :remote_chef_zero_port,
           long: '--remote-chef-zero-port PORT',
           description: 'Listen port on remote',
           default: nil,
           proc: proc { |key| Chef::Config[:remote_chef_zero_port] = key.to_i }

    option :alter_project,
           long: '--alter-project PROJECT',
           proc: proc { |u| Chef::Config[:alter_project] = u },
           description: 'Products used on remote nodes',
           default: 'chef',
           in: %w{chef cinc}

    option :node_config_file,
           long: '--node-config PATH_TO_CONFIG',
           proc: proc { |u| Chef::Config[:node_config_file] = u },
           description: 'The configuration file to use on remote node',
           default: '/etc/chef/client.rb'
  end
end

Private Instance Methods

locate_config_value(key) click to toggle source
# File lib/chef/knife/zero_base.rb, line 50
def locate_config_value(key)
  key = key.to_sym
  Chef::Config[:knife][key] || config[key]
end