Class: Ridley::BootstrapContext::Base
- Inherits:
-
Object
- Object
- Ridley::BootstrapContext::Base
- Defined in:
- lib/ridley/bootstrap_context.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#bootstrap_proxy ⇒ Object
readonly
Returns the value of attribute bootstrap_proxy.
-
#chef_version ⇒ Object
readonly
Returns the value of attribute chef_version.
-
#encrypted_data_bag_secret ⇒ Object
readonly
Returns the value of attribute encrypted_data_bag_secret.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#hints ⇒ Object
readonly
Returns the value of attribute hints.
-
#node_name ⇒ Object
readonly
Returns the value of attribute node_name.
-
#run_list ⇒ Object
readonly
Returns the value of attribute run_list.
-
#server_url ⇒ Object
readonly
Returns the value of attribute server_url.
-
#template_file ⇒ Object
readonly
Returns the value of attribute template_file.
-
#validator_client ⇒ Object
readonly
Returns the value of attribute validator_client.
-
#validator_path ⇒ Object
readonly
Returns the value of attribute validator_path.
Class Method Summary collapse
Instance Method Summary collapse
- #bootstrap_command ⇒ String
- #default_template ⇒ String
- #first_boot ⇒ String
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #template ⇒ Erubis::Eruby
- #templates_path ⇒ Pathname
-
#validation_key ⇒ String
The validation key to create a new client for the node.
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ridley/bootstrap_context.rb', line 31 def initialize( = {}) = .reverse_merge( validator_client: "chef-validator", attributes: Hash.new, run_list: Array.new, environment: "_default", sudo: true, hints: Hash.new, chef_version: "latest" ) [: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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
26 27 28 |
# File 'lib/ridley/bootstrap_context.rb', line 26 def attributes @attributes end |
#bootstrap_proxy ⇒ Object (readonly)
Returns the value of attribute bootstrap_proxy.
19 20 21 |
# File 'lib/ridley/bootstrap_context.rb', line 19 def bootstrap_proxy @bootstrap_proxy end |
#chef_version ⇒ Object (readonly)
Returns the value of attribute chef_version.
20 21 22 |
# File 'lib/ridley/bootstrap_context.rb', line 20 def chef_version @chef_version end |
#encrypted_data_bag_secret ⇒ Object (readonly)
Returns the value of attribute encrypted_data_bag_secret.
22 23 24 |
# File 'lib/ridley/bootstrap_context.rb', line 22 def encrypted_data_bag_secret @encrypted_data_bag_secret end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
28 29 30 |
# File 'lib/ridley/bootstrap_context.rb', line 28 def environment @environment end |
#hints ⇒ Object (readonly)
Returns the value of attribute hints.
29 30 31 |
# File 'lib/ridley/bootstrap_context.rb', line 29 def hints @hints end |
#node_name ⇒ Object (readonly)
Returns the value of attribute node_name.
25 26 27 |
# File 'lib/ridley/bootstrap_context.rb', line 25 def node_name @node_name end |
#run_list ⇒ Object (readonly)
Returns the value of attribute run_list.
27 28 29 |
# File 'lib/ridley/bootstrap_context.rb', line 27 def run_list @run_list end |
#server_url ⇒ Object (readonly)
Returns the value of attribute server_url.
23 24 25 |
# File 'lib/ridley/bootstrap_context.rb', line 23 def server_url @server_url end |
#template_file ⇒ Object (readonly)
Returns the value of attribute template_file.
18 19 20 |
# File 'lib/ridley/bootstrap_context.rb', line 18 def template_file @template_file end |
#validator_client ⇒ Object (readonly)
Returns the value of attribute validator_client.
24 25 26 |
# File 'lib/ridley/bootstrap_context.rb', line 24 def validator_client @validator_client end |
#validator_path ⇒ Object (readonly)
Returns the value of attribute validator_path.
21 22 23 |
# File 'lib/ridley/bootstrap_context.rb', line 21 def validator_path @validator_path end |
Class Method Details
.validate_options(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/ridley/bootstrap_context.rb', line 7 def ( = {}) if [:server_url].nil? raise Errors::ArgumentError, "A server_url is required for bootstrapping" end if [:validator_path].nil? raise Errors::ArgumentError, "A path to a validator is required for bootstrapping" end end |
Instance Method Details
#bootstrap_command ⇒ String
60 61 62 |
# File 'lib/ridley/bootstrap_context.rb', line 60 def bootstrap_command raise RuntimeError, "abstract function: must be implemented on includer" end |
#default_template ⇒ String
65 66 67 |
# File 'lib/ridley/bootstrap_context.rb', line 65 def default_template raise RuntimeError, "abstract function: must be implemented on includer" end |
#first_boot ⇒ String
75 76 77 |
# File 'lib/ridley/bootstrap_context.rb', line 75 def first_boot JSON.fast_generate(attributes.merge(run_list: run_list)) end |
#template ⇒ Erubis::Eruby
91 92 93 |
# File 'lib/ridley/bootstrap_context.rb', line 91 def template Erubis::Eruby.new(IO.read(template_file).chomp) end |
#templates_path ⇒ Pathname
70 71 72 |
# File 'lib/ridley/bootstrap_context.rb', line 70 def templates_path Ridley.root.join('bootstrappers') end |
#validation_key ⇒ String
The validation key to create a new client for the node
84 85 86 87 88 |
# File 'lib/ridley/bootstrap_context.rb', line 84 def validation_key IO.read(File.(validator_path)).chomp rescue Errno::ENOENT raise Errors::ValidatorNotFound, "Error bootstrapping: Validator not found at '#{validator_path}'" end |