Class: Chef::Knife::Bootstrap::ClientBuilder
- Inherits:
-
Object
- Object
- Chef::Knife::Bootstrap::ClientBuilder
- Defined in:
- lib/chef/knife/bootstrap/client_builder.rb
Instance Attribute Summary collapse
-
#chef_config ⇒ Hash
Chef config object.
-
#knife_config ⇒ Hash
Knife merged config, typically @config.
-
#ui ⇒ Chef::Knife::UI
Ui object for output.
Instance Method Summary collapse
-
#client_path ⇒ String
Tempfile to use to write newly created client credentials to.
-
#initialize(knife_config: {}, chef_config: {}, ui: nil) ⇒ ClientBuilder
constructor
A new instance of ClientBuilder.
-
#run ⇒ Object
Main entry.
Constructor Details
#initialize(knife_config: {}, chef_config: {}, ui: nil) ⇒ ClientBuilder
Returns a new instance of ClientBuilder.
40 41 42 43 44 |
# File 'lib/chef/knife/bootstrap/client_builder.rb', line 40 def initialize(knife_config: {}, chef_config: {}, ui: nil) @knife_config = knife_config @chef_config = chef_config @ui = ui end |
Instance Attribute Details
#chef_config ⇒ Hash
Returns chef config object.
33 34 35 |
# File 'lib/chef/knife/bootstrap/client_builder.rb', line 33 def chef_config @chef_config end |
#knife_config ⇒ Hash
Returns knife merged config, typically @config.
31 32 33 |
# File 'lib/chef/knife/bootstrap/client_builder.rb', line 31 def knife_config @knife_config end |
#ui ⇒ Chef::Knife::UI
Returns ui object for output.
35 36 37 |
# File 'lib/chef/knife/bootstrap/client_builder.rb', line 35 def ui @ui end |
Instance Method Details
#client_path ⇒ String
Tempfile to use to write newly created client credentials to.
This method is public so that the knife bootstrapper can read then and pass the value into the handler for chef vault which needs the client cert we create here.
We hang onto the tmpdir as an ivar as well so that it will not get GC’d and removed
68 69 70 71 72 73 74 |
# File 'lib/chef/knife/bootstrap/client_builder.rb', line 68 def client_path @client_path ||= begin @tmpdir = Dir.mktmpdir File.join(@tmpdir, "#{node_name}.pem") end end |
#run ⇒ Object
Main entry. Prompt the user to clean up any old client or node objects. Then create the new client, then create the new node.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/chef/knife/bootstrap/client_builder.rb', line 48 def run sanity_check ui.info("Creating new client for #{node_name}") create_client! ui.info("Creating new node for #{node_name}") create_node! end |