Class: Ridley::Node
- Inherits:
-
Object
- Object
- Ridley::Node
- Includes:
- Resource
- Defined in:
- lib/ridley/resources/node.rb
Overview
Class Method Summary collapse
Instance Method Summary collapse
- #automatic=(hash) ⇒ Object (also: #automatic_attributes=)
-
#chef_client ⇒ SSH::Response
Run Chef-Client on the instantiated node.
-
#cloud? ⇒ Boolean
Returns true if the node is identified as a cloud node.
-
#cloud_provider ⇒ nil, String
Returns the cloud provider of the instantiated node.
- #default=(hash) ⇒ Object (also: #default_attributes=)
-
#ec2? ⇒ Boolean
Returns true if the node is identified as a cloud node using the ec2 provider.
-
#eucalyptus? ⇒ Boolean
Returns true if the node is identified as a cloud node using the eucalyptus provider.
- #normal=(hash) ⇒ Object (also: #normal_attributes=)
- #override=(hash) ⇒ Object (also: #override_attributes=)
-
#public_hostname ⇒ String
Returns the public hostname of the instantiated node.
-
#public_ipv4 ⇒ String
(also: #public_ipaddress)
Returns the public IPv4 address of the instantiated node.
-
#rackspace? ⇒ Boolean
Returns true if the node is identified as a cloud node using the rackspace provider.
-
#set_attribute(key, value) ⇒ HashWithIndifferentAccess
Set a node level normal attribute given the dotted path representation of the Chef attribute and value.
Methods included from Resource
#<=>, #==, #attribute, #attribute=, #attribute?, #attributes, #attributes=, #chef_id, #eql?, #from_hash, #from_json, #hash, #initialize, #reload, #save, #to_hash, #to_json, #to_s
Class Method Details
.bootstrap(connection, nodes, options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ridley/resources/node.rb', line 34 def bootstrap(connection, *args) = args.last.is_a?(Hash) ? args.pop : Hash.new = { server_url: connection.server_url, ssh_user: connection.ssh[:user], ssh_password: connection.ssh[:password], ssh_timeout: connection.ssh[:timeout], validator_path: connection.validator_path, validator_client: connection.validator_client, encrypted_data_bag_secret_path: connection.encrypted_data_bag_secret_path } = .merge() Bootstrapper.new(args, ).run end |
Instance Method Details
#automatic=(hash) ⇒ Object Also known as: automatic_attributes=
82 83 84 |
# File 'lib/ridley/resources/node.rb', line 82 def automatic=(hash) super(HashWithIndifferentAccess.new(hash)) end |
#chef_client ⇒ SSH::Response
Run Chef-Client on the instantiated node
188 189 190 191 192 |
# File 'lib/ridley/resources/node.rb', line 188 def chef_client Ridley::SSH.start(self, connection.ssh) do |ssh| ssh.run("sudo chef-client").first end end |
#cloud? ⇒ Boolean
Returns true if the node is identified as a cloud node.
160 161 162 |
# File 'lib/ridley/resources/node.rb', line 160 def cloud? self.automatic.has_key?(:cloud) end |
#cloud_provider ⇒ nil, String
Returns the cloud provider of the instantiated node. If the node is not identified as a cloud node, then nil is returned.
153 154 155 |
# File 'lib/ridley/resources/node.rb', line 153 def cloud_provider self.cloud? ? self.automatic[:cloud][:provider] : nil end |
#default=(hash) ⇒ Object Also known as: default_attributes=
88 89 90 |
# File 'lib/ridley/resources/node.rb', line 88 def default=(hash) super(HashWithIndifferentAccess.new(hash)) end |
#ec2? ⇒ Boolean
Returns true if the node is identified as a cloud node using the ec2 provider.
174 175 176 |
# File 'lib/ridley/resources/node.rb', line 174 def ec2? self.cloud_provider == "ec2" end |
#eucalyptus? ⇒ Boolean
Returns true if the node is identified as a cloud node using the eucalyptus provider.
167 168 169 |
# File 'lib/ridley/resources/node.rb', line 167 def eucalyptus? self.cloud_provider == "eucalyptus" end |
#normal=(hash) ⇒ Object Also known as: normal_attributes=
76 77 78 |
# File 'lib/ridley/resources/node.rb', line 76 def normal=(hash) super(HashWithIndifferentAccess.new(hash)) end |
#override=(hash) ⇒ Object Also known as: override_attributes=
94 95 96 |
# File 'lib/ridley/resources/node.rb', line 94 def override=(hash) super(HashWithIndifferentAccess.new(hash)) end |
#public_hostname ⇒ String
Returns the public hostname of the instantiated node. This hostname should be used for public communications to the node.
127 128 129 |
# File 'lib/ridley/resources/node.rb', line 127 def public_hostname self.cloud? ? self.automatic[:cloud][:public_hostname] : self.automatic[:fqdn] end |
#public_ipv4 ⇒ String Also known as: public_ipaddress
Returns the public IPv4 address of the instantiated node. This ip address should be used for public communications to the node.
138 139 140 |
# File 'lib/ridley/resources/node.rb', line 138 def public_ipv4 self.cloud? ? self.automatic[:cloud][:public_ipv4] : self.automatic[:ipaddress] end |
#rackspace? ⇒ Boolean
Returns true if the node is identified as a cloud node using the rackspace provider.
181 182 183 |
# File 'lib/ridley/resources/node.rb', line 181 def rackspace? self.cloud_provider == "rackspace" end |
#set_attribute(key, value) ⇒ HashWithIndifferentAccess
It is not possible to set any other attribute level on a node and have it persist after a Chef Run. This is because all other attribute levels are truncated at the start of a Chef Run.
Set a node level normal attribute given the dotted path representation of the Chef attribute and value.
115 116 117 118 |
# File 'lib/ridley/resources/node.rb', line 115 def set_attribute(key, value) attr_hash = HashWithIndifferentAccess.from_dotted_path(key, value) self.normal = self.normal.deep_merge(attr_hash) end |