Class: Ridley::UnixTemplateBinding
- Inherits:
-
Object
- Object
- Ridley::UnixTemplateBinding
- Includes:
- BootstrapBinding
- Defined in:
- lib/ridley/bootstrap_bindings/unix_template_binding.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
-
#hints ⇒ Object
readonly
Returns the value of attribute hints.
-
#sudo ⇒ Object
readonly
Returns the value of attribute sudo.
Attributes included from BootstrapBinding
#attributes, #bootstrap_proxy, #chef_version, #default_options, #encrypted_data_bag_secret, #environment, #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 = {}) ⇒ UnixTemplateBinding
constructor
A new instance of UnixTemplateBinding.
Methods included from BootstrapBinding
#first_boot, included, #template, #templates_path, #validation_key
Constructor Details
#initialize(options = {}) ⇒ UnixTemplateBinding
Returns a new instance of UnixTemplateBinding.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ridley/bootstrap_bindings/unix_template_binding.rb', line 35 def initialize( = {}) = self.class..merge() [:template] ||= default_template self.class.() @template_file = [:template] @bootstrap_proxy = [:bootstrap_proxy] @chef_version = [:chef_version] @sudo = [:sudo] @validator_path = [:validator_path] @encrypted_data_bag_secret = [:encrypted_data_bag_secret] @hints = [:hints] @server_url = [:server_url] @validator_client = [:validator_client] @node_name = [:node_name] @attributes = [:attributes] @run_list = [:run_list] @environment = [:environment] end |
Instance Attribute Details
#hints ⇒ Object (readonly)
Returns the value of attribute hints.
12 13 14 |
# File 'lib/ridley/bootstrap_bindings/unix_template_binding.rb', line 12 def hints @hints end |
#sudo ⇒ Object (readonly)
Returns the value of attribute sudo.
11 12 13 |
# File 'lib/ridley/bootstrap_bindings/unix_template_binding.rb', line 11 def sudo @sudo end |
Instance Method Details
#boot_command ⇒ String
56 57 58 59 60 61 62 63 64 |
# File 'lib/ridley/bootstrap_bindings/unix_template_binding.rb', line 56 def boot_command cmd = template.evaluate(self) if sudo cmd = "sudo #{cmd}" end cmd end |
#bootstrap_directory ⇒ String
94 95 96 |
# File 'lib/ridley/bootstrap_bindings/unix_template_binding.rb', line 94 def bootstrap_directory "/etc/chef" end |
#chef_config ⇒ String
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ridley/bootstrap_bindings/unix_template_binding.rb', line 67 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
99 100 101 |
# File 'lib/ridley/bootstrap_bindings/unix_template_binding.rb', line 99 def chef_run "chef-client -j #{bootstrap_directory}/first-boot.json -E #{environment}" end |
#default_template ⇒ String
104 105 106 |
# File 'lib/ridley/bootstrap_bindings/unix_template_binding.rb', line 104 def default_template templates_path.join('unix_omnibus.erb').to_s end |