Class: ImageBuilder::Provisioners::Chef::Client

Inherits:
Base
  • Object
show all
Defined in:
lib/image_builder/provisioners/chef_client.rb

Overview

Generic class doc comment

Constant Summary

Constants included from ImageBuilder

VERSION

Instance Attribute Summary collapse

Attributes inherited from Base

#chef_version, #config_template, #cookbook_paths, #encrypted_data_bag_secret_path, #execute_command, #install_command, #json, #prevent_sudo, #run_list, #skip_install, #staging_directory, #type

Instance Method Summary collapse

Methods inherited from Base

#cookbook_path, #encrypted_data_bag_secret, from_file

Constructor Details

#initializeClient



18
19
20
21
22
23
# 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

Instance Attribute Details

#chef_environmentObject

Returns the value of attribute chef_environment.



10
11
12
# File 'lib/image_builder/provisioners/chef_client.rb', line 10

def chef_environment
  @chef_environment
end

#node_name(name = nil) ⇒ Object

Map chef-client provisioner knife.rb config options to their corresponding object attributes



27
28
29
# File 'lib/image_builder/provisioners/chef_client.rb', line 27

def node_name
  @node_name
end

#server_urlObject

required



12
13
14
# File 'lib/image_builder/provisioners/chef_client.rb', line 12

def server_url
  @server_url
end

#skip_clean_clientObject

Returns the value of attribute skip_clean_client.



13
14
15
# File 'lib/image_builder/provisioners/chef_client.rb', line 13

def skip_clean_client
  @skip_clean_client
end

#skip_clean_nodeObject

Returns the value of attribute skip_clean_node.



14
15
16
# File 'lib/image_builder/provisioners/chef_client.rb', line 14

def skip_clean_node
  @skip_clean_node
end

#validation_client_name(name = nil) ⇒ Object

Since this has an attr_accessor of the same name, need to write this as a getter & setter method



38
39
40
# File 'lib/image_builder/provisioners/chef_client.rb', line 38

def validation_client_name
  @validation_client_name
end

#validation_key_pathObject

Returns the value of attribute validation_key_path.



16
17
18
# File 'lib/image_builder/provisioners/chef_client.rb', line 16

def validation_key_path
  @validation_key_path
end

Instance Method Details

#chef_server_url(url) ⇒ Object



32
33
34
# File 'lib/image_builder/provisioners/chef_client.rb', line 32

def chef_server_url(url)
  @server_url = url
end

#packer_hashObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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) ⇒ Object



43
44
45
# File 'lib/image_builder/provisioners/chef_client.rb', line 43

def validation_key(key)
  @validation_key_path = fixup_key_path(key)
end