Class: Ridley::BootstrapContext::Unix
- Defined in:
- lib/ridley/bootstrap_context/unix.rb
Overview
Represents a binding that will be evaluated as an ERB template. When bootstrapping nodes, an instance of this class represents the customizable and necessary configurations needed by the Host in order to install and connect to Chef. By default, this class will be used when SSH is the best way to connect to the node.
Instance Attribute Summary collapse
-
#sudo ⇒ Object
readonly
Returns the value of attribute sudo.
Attributes inherited from Base
#attributes, #bootstrap_proxy, #chef_version, #encrypted_data_bag_secret, #environment, #hints, #node_name, #run_list, #server_url, #template_file, #validator_client, #validator_path
Instance Method Summary collapse
- #boot_command ⇒ String
- #bootstrap_directory ⇒ String
- #chef_config ⇒ String
- #chef_run ⇒ String
- #default_template ⇒ String
-
#initialize(options = {}) ⇒ Unix
constructor
A new instance of Unix.
Methods inherited from Base
#bootstrap_command, #first_boot, #template, #templates_path, validate_options, #validation_key
Constructor Details
#initialize(options = {}) ⇒ Unix
Returns a new instance of Unix.
12 13 14 15 16 |
# File 'lib/ridley/bootstrap_context/unix.rb', line 12 def initialize( = {}) = .reverse_merge(sudo: true) @sudo = [:sudo] super() end |
Instance Attribute Details
#sudo ⇒ Object (readonly)
Returns the value of attribute sudo.
8 9 10 |
# File 'lib/ridley/bootstrap_context/unix.rb', line 8 def sudo @sudo end |
Instance Method Details
#boot_command ⇒ String
19 20 21 22 23 24 25 26 27 |
# File 'lib/ridley/bootstrap_context/unix.rb', line 19 def boot_command cmd = template.evaluate(self) if sudo cmd = "sudo #{cmd}" end cmd end |
#bootstrap_directory ⇒ String
57 58 59 |
# File 'lib/ridley/bootstrap_context/unix.rb', line 57 def bootstrap_directory "/etc/chef" end |
#chef_config ⇒ String
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ridley/bootstrap_context/unix.rb', line 30 def chef_config body = <<-CONFIG log_level :info log_location STDOUT chef_server_url "#{server_url}" validation_client_name "#{validator_client}" CONFIG if node_name.present? body << %Q{node_name "#{node_name}"\n} else body << "# Using default node name (fqdn)\n" end if bootstrap_proxy.present? body << %Q{http_proxy "#{bootstrap_proxy}"\n} body << %Q{https_proxy "#{bootstrap_proxy}"\n} end if encrypted_data_bag_secret.present? body << %Q{encrypted_data_bag_secret "#{bootstrap_directory}/encrypted_data_bag_secret"\n} end body end |
#chef_run ⇒ String
62 63 64 |
# File 'lib/ridley/bootstrap_context/unix.rb', line 62 def chef_run "chef-client -j #{bootstrap_directory}/first-boot.json -E #{environment}" end |
#default_template ⇒ String
67 68 69 |
# File 'lib/ridley/bootstrap_context/unix.rb', line 67 def default_template templates_path.join('unix_omnibus.erb').to_s end |