class ImageBuilder::Provisioners::Chef::Client
Generic class doc comment
Attributes
chef_environment[RW]
node_name[RW]
server_url[RW]
skip_clean_client[RW]
skip_clean_node[RW]
validation_client_name[RW]
validation_key_path[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
ImageBuilder::Provisioners::Chef::Base::new
# File lib/image_builder/provisioners/chef_client.rb, line 18 def initialize super @skip_clean_client = false @skip_clean_node = false @type = 'chef-client' end
Public Instance Methods
chef_server_url(url)
click to toggle source
# File lib/image_builder/provisioners/chef_client.rb, line 32 def chef_server_url(url) @server_url = url end
packer_hash()
click to toggle source
Calls superclass method
ImageBuilder::Provisioners::Chef::Base#packer_hash
# File lib/image_builder/provisioners/chef_client.rb, line 47 def packer_hash hash = super # Required attrs attr_to_hash(hash, :server_url, true) # Optional attrs attr_to_hash(hash, :chef_environment) attr_to_hash(hash, :node_name) attr_to_hash(hash, :skip_clean_client) attr_to_hash(hash, :skip_clean_node) attr_to_hash(hash, :validation_client_name) attr_to_hash(hash, :validation_key_path) hash end
validation_key(key)
click to toggle source
# File lib/image_builder/provisioners/chef_client.rb, line 43 def validation_key(key) @validation_key_path = fixup_key_path(key) end
Private Instance Methods
check_file(path)
click to toggle source
rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
# File lib/image_builder/provisioners/chef_client.rb, line 104 def check_file(path) return path if ::File.exist?(path) nil end
fixup_key_path(path)
click to toggle source
This may not come in as a valid file after reading knife.rb, try some fixups rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
# File lib/image_builder/provisioners/chef_client.rb, line 68 def fixup_key_path(path) return path if path.nil? || path.empty? unless ::File.exist?(path) file_name = ::File.basename(path) sec_var = @encrypted_data_bag_secret_path sec_env = ENV['ENCRYPTED_DATA_BAG_SECRET'] # Pearson-centric env vars merle_key = ENV['MERLE_VALIDATOR'] path = check_file(merle_key) if valid_path?(merle_key) merle = ENV['MERLE'] path = check_file(::File.join(merle, file_name)) if valid_path?(merle) && path.nil? # 'standard' location checks if valid_path?(@knife_file) && path.nil? dir = ::File.dirname(@knife_file) path = check_file(::File.join(dir, file_name)) end if valid_path?(sec_var) && path.nil? dir = ::File.dirname(sec_var) path = check_file(::File.join(dir, file_name)) end if valid_path?(sec_env) && path.nil? dir = ::File.dirname(sec_env) path = check_file(::File.join(dir, file_name)) end end path end
valid_path?(path)
click to toggle source
# File lib/image_builder/provisioners/chef_client.rb, line 109 def valid_path?(path) !path.nil? && !path.strip.empty? end