Class: Chef::Knife::Cloud::BootstrapProtocol

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb

Direct Known Subclasses

SshBootstrapProtocol, WinrmBootstrapProtocol

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#after_exec_command, #before_exec_command, #create_service_instance, #execute_command, #msg_pair, #pretty_key, #set_default_config, #validate!, #validate_params!

Constructor Details

#initialize(config) ⇒ BootstrapProtocol

Returns a new instance of BootstrapProtocol.



32
33
34
35
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 32

def initialize(config)
  @config = config
  @ui ||= Chef::Knife::UI.new(STDOUT, STDERR, STDIN, {})
end

Instance Attribute Details

#bootstrapObject

Returns the value of attribute bootstrap.



29
30
31
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 29

def bootstrap
  @bootstrap
end

#configObject (readonly)

Returns the value of attribute config.



30
31
32
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 30

def config
  @config
end

#initial_sleep_delayObject

Returns the value of attribute initial_sleep_delay.



29
30
31
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 29

def initial_sleep_delay
  @initial_sleep_delay
end

#uiObject

Returns the value of attribute ui.



29
30
31
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 29

def ui
  @ui
end

Instance Method Details

#init_bootstrap_optionsObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 47

def init_bootstrap_options
  # set the command bootstrap options.
  bootstrap.name_args << config[:bootstrap_ip_address]
  bootstrap.config[:chef_node_name] = config[:chef_node_name]
  bootstrap.config[:run_list] = config[:run_list]
  bootstrap.config[:prerelease] = config[:prerelease]
  bootstrap.config[:bootstrap_version] = config[:bootstrap_version]
  bootstrap.config[:bootstrap_proxy] = config[:bootstrap_proxy]
  bootstrap.config[:environment] = config[:environment]
  # see chef/knife/bootstrap.rb #warn_chef_config_secret_key.
  bootstrap.config[:encrypted_data_bag_secret] = config[:encrypted_data_bag_secret]
  bootstrap.config[:encrypted_data_bag_secret_file] = config[:encrypted_data_bag_secret_file]
  bootstrap.config[:first_boot_attributes] = config[:first_boot_attributes]
  bootstrap.config[:secret] = config[:secret]
  bootstrap.config[:secret_file] = config[:secret_file]
  bootstrap.config[:bootstrap_template] = config[:bootstrap_template]
  bootstrap.config[:node_ssl_verify_mode] = config[:node_ssl_verify_mode]
  bootstrap.config[:node_verify_api_cert] = config[:node_verify_api_cert]
  bootstrap.config[:bootstrap_no_proxy] = config[:bootstrap_no_proxy]
  bootstrap.config[:bootstrap_url] = config[:bootstrap_url]
  bootstrap.config[:bootstrap_install_command] = config[:bootstrap_install_command]
  bootstrap.config[:bootstrap_wget_options] = config[:bootstrap_wget_options]
  bootstrap.config[:bootstrap_curl_options] = config[:bootstrap_curl_options]
  bootstrap.config[:bootstrap_vault_file] = config[:bootstrap_vault_file]
  bootstrap.config[:bootstrap_vault_json] = config[:bootstrap_vault_json]
  bootstrap.config[:bootstrap_vault_item] = config[:bootstrap_vault_item]
  bootstrap.config[:use_sudo_password] = config[:use_sudo_password]
  bootstrap.config[:msi_url] = config[:msi_url]
  bootstrap.config[:install_as_service] = config[:install_as_service]
  bootstrap.config[:session_timeout] = config[:session_timeout]
  bootstrap.config[:channel] = config[:channel]
  bootstrap.config[:bootstrap_product] = config[:bootstrap_product]
end

#send_bootstrap_commandObject



41
42
43
44
45
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 41

def send_bootstrap_command
  wait_for_server_ready
  init_bootstrap_options
  @bootstrap.run
end

#wait_for_server_readyObject

Raises:

  • (Chef::Exceptions::Override)


37
38
39
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 37

def wait_for_server_ready
  raise Chef::Exceptions::Override, "You must override wait_for_server_ready in #{self}"
end