Parent

Files

Class/Module Index [+]

Quicksearch

Chef::Knife::Core::BootstrapContext

Instances of BootstrapContext are the context objects (i.e., self) for bootstrap templates. For backwards compatability, they must set the following instance variables:

Public Class Methods

new(config, run_list, chef_config) click to toggle source
# File lib/chef/knife/core/bootstrap_context.rb, line 31
def initialize(config, run_list, chef_config)
  @config       = config
  @run_list     = run_list
  @chef_config  = chef_config
end

Public Instance Methods

bootstrap_environment() click to toggle source
# File lib/chef/knife/core/bootstrap_context.rb, line 45
def bootstrap_environment
  @chef_config[:environment] || '_default'
end
bootstrap_version_string() click to toggle source
# File lib/chef/knife/core/bootstrap_context.rb, line 37
def bootstrap_version_string
  if @config[:prerelease]
    "--prerelease"
  else
    "--version #{chef_version}"
  end
end
chef_version() click to toggle source
# File lib/chef/knife/core/bootstrap_context.rb, line 94
def chef_version
  knife_config[:bootstrap_version] || Chef::VERSION
end
config_content() click to toggle source
# File lib/chef/knife/core/bootstrap_context.rb, line 57
def config_content
  client_rb = log_level        :autolog_location     STDOUTchef_server_url  "#{@chef_config[:chef_server_url]}"validation_client_name "#{@chef_config[:validation_client_name]}"
  if @config[:chef_node_name]
    client_rb << %{node_name "#{@config[:chef_node_name]}"\n}
  else
    client_rb << "# Using default node name (fqdn)\n"
  end

  if knife_config[:bootstrap_proxy]
    client_rb << %{http_proxy        "#{knife_config[:bootstrap_proxy]}"\n}
    client_rb << %{https_proxy       "#{knife_config[:bootstrap_proxy]}"\n}
  end

  if @chef_config[:encrypted_data_bag_secret]
    client_rb << %{encrypted_data_bag_secret "/etc/chef/encrypted_data_bag_secret"\n}
  end

  client_rb
end
encrypted_data_bag_secret() click to toggle source
# File lib/chef/knife/core/bootstrap_context.rb, line 53
def encrypted_data_bag_secret
  IO.read(File.expand_path(@chef_config[:encrypted_data_bag_secret]))
end
first_boot() click to toggle source
# File lib/chef/knife/core/bootstrap_context.rb, line 98
def first_boot
  (@config[:first_boot_attributes] || {}).merge(:run_list => @run_list)
end
knife_config() click to toggle source
# File lib/chef/knife/core/bootstrap_context.rb, line 90
def knife_config
  @chef_config.key?(:knife) ? @chef_config[:knife] : {}
end
start_chef() click to toggle source
# File lib/chef/knife/core/bootstrap_context.rb, line 82
def start_chef
  # If the user doesn't have a client path configure, let bash use the PATH for what it was designed for
  client_path = @chef_config[:chef_client_path] || 'chef-client'
  s = "#{client_path} -j /etc/chef/first-boot.json"
  s << " -E #{bootstrap_environment}" if chef_version.to_f != 0.9 # only use the -E option on Chef 0.10+
  s
end
validation_key() click to toggle source
# File lib/chef/knife/core/bootstrap_context.rb, line 49
def validation_key
  IO.read(File.expand_path(@chef_config[:validation_key]))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.