class ImageBuilder::Provisioners::Chef::Base
Generic class doc comment
Attributes
chef_version[RW]
config_template[RW]
cookbook_paths[RW]
encrypted_data_bag_secret_path[RW]
execute_command[RW]
install_command[RW]
json[RW]
knife_file[R]
prevent_sudo[RW]
run_list[RW]
skip_install[RW]
staging_directory[RW]
type[R]
Public Class Methods
from_file(path)
click to toggle source
set attributes from something that looks like a knife.rb file
# File lib/image_builder/provisioners/chef_base.rb, line 31 def self.from_file(path) inst = new @knife_file = ::File.expand_path(path) # For knife hash params in knife.rb knife = {} # rubocop:disable Lint/UselessAssignment inst.instance_eval(IO.read(@knife_file)) inst end
new()
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 24 def initialize @prevent_sudo = false @skip_install = false @encrypted_data_bag_secret_path = ENV['ENCRYPTED_DATA_BAG_SECRET'] end
Public Instance Methods
cookbook_path(path)
click to toggle source
While not used explicitly in the chef-client provisioner, this will give us consistent behavior across chef provisioners if we need to do a local cookbook lookup
# File lib/image_builder/provisioners/chef_base.rb, line 53 def cookbook_path(path) @cookbook_paths = [ENV['COOKBOOK_PATH']] << path @cookbook_paths.flatten! @cookbook_paths.compact! @cookbook_paths.uniq! end
encrypted_data_bag_secret(sec)
click to toggle source
Map knife.rb config options to their corresponding object attributes the :encrypted_data_bag_secret_path attribute is specific to the chef-solo provisioner, but we'll need it for all chef provisioners, since we need to upload it to the node before provisioning via the chef-client provisioner
# File lib/image_builder/provisioners/chef_base.rb, line 46 def encrypted_data_bag_secret(sec) @encrypted_data_bag_secret_path = sec end
packer_hash()
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 60 def packer_hash hash = { type: @type } unless @chef_version.nil? && @install_command.nil? @install_command = 'curl -L https://www.opscode.com/chef/install.sh | ' @install_command += 'sudo ' unless @prevent_sudo @install_command += 'bash -s -- -v ' + @chef_version end attr_to_hash(hash, :config_template) attr_to_hash(hash, :execute_command) attr_to_hash(hash, :install_command) attr_to_hash(hash, :json) attr_to_hash(hash, :prevent_sudo) attr_to_hash(hash, :run_list) attr_to_hash(hash, :skip_install) attr_to_hash(hash, :staging_directory) hash end
Protected Instance Methods
cache_options(_opts)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 96 def cache_options(_opts) end
cache_type(_type)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 95 def cache_type(_type) end
chef_server_url(_url)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 94 def chef_server_url(_url) end
client_key(_key)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 91 def client_key(_key) end
cookbook_copyright(_x)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 97 def cookbook_copyright(_x) end
cookbook_email(_mail)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 98 def cookbook_email(_mail) end
log_level(_lvl)
click to toggle source
These attributes might be found in a knife.rb file, but may not be used for a specific provisioner. This is only here to ensure the instance_eval in the from_file
method (above) passes
# File lib/image_builder/provisioners/chef_base.rb, line 88 def log_level(_lvl) end
log_location(_loc)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 89 def log_location(_loc) end
name(_name = nil)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 99 def name(_name = nil) end
node_name(_name)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 90 def node_name(_name) end
validation_client_name(_client)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 92 def validation_client_name(_client) end
validation_key(_key)
click to toggle source
# File lib/image_builder/provisioners/chef_base.rb, line 93 def validation_key(_key) end