Class: Ridley::NodeResource
- Includes:
- Logging
- Defined in:
- lib/ridley/resources/node_resource.rb
Instance Attribute Summary collapse
-
#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.
-
#server_url ⇒ Object
readonly
Returns the value of attribute server_url.
-
#ssh ⇒ Object
readonly
Returns the value of attribute ssh.
-
#validator_client ⇒ Object
readonly
Returns the value of attribute validator_client.
-
#validator_path ⇒ Object
readonly
Returns the value of attribute validator_path.
-
#winrm ⇒ Object
readonly
Returns the value of attribute winrm.
Instance Method Summary collapse
- #bootstrap(host, options = {}) ⇒ HostConnector::Response
-
#chef_run(host) ⇒ HostConnector::Response
Executes a Chef run using the best worker available for the given host.
-
#initialize(connection_registry, options = {}) ⇒ NodeResource
constructor
A new instance of NodeResource.
-
#merge_data(target, options = {}) ⇒ Ridley::NodeObject
Merges the given data with the the data of the target node on the remote.
-
#put_secret(host) ⇒ HostConnector::Response
Puts a secret on the host using the best worker available for the given host.
-
#ruby_script(host, command_lines) ⇒ HostConnector::Response
Executes an arbitrary ruby script using the best worker available for the given host.
-
#run(host, command) ⇒ Array<Symbol, HostConnector::Response>
(also: #execute_command)
Executes the given command on a node using the best worker available for the given host.
-
#uninstall_chef(host, options = {}) ⇒ HostConnector::Response
Uninstall Chef from a node.
Methods included from Logging
Methods inherited from Resource
#all, #connection, #create, #delete, #delete_all, #find, #new, representation, represented_by, resource_path, set_resource_path, #update
Constructor Details
#initialize(connection_registry, options = {}) ⇒ NodeResource
Returns a new instance of NodeResource.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ridley/resources/node_resource.rb', line 38 def initialize(connection_registry, = {}) super(connection_registry) @server_url = [:server_url] @validator_path = [:validator_path] @validator_client = [:validator_client] @encrypted_data_bag_secret = [:encrypted_data_bag_secret] @ssh = [:ssh] @winrm = [:winrm] @chef_version = [:chef_version] @host_commander = HostCommander.new_link end |
Instance Attribute Details
#chef_version ⇒ Object (readonly)
Returns the value of attribute chef_version.
14 15 16 |
# File 'lib/ridley/resources/node_resource.rb', line 14 def chef_version @chef_version end |
#encrypted_data_bag_secret ⇒ Object (readonly)
Returns the value of attribute encrypted_data_bag_secret.
11 12 13 |
# File 'lib/ridley/resources/node_resource.rb', line 11 def encrypted_data_bag_secret @encrypted_data_bag_secret end |
#server_url ⇒ Object (readonly)
Returns the value of attribute server_url.
8 9 10 |
# File 'lib/ridley/resources/node_resource.rb', line 8 def server_url @server_url end |
#ssh ⇒ Object (readonly)
Returns the value of attribute ssh.
12 13 14 |
# File 'lib/ridley/resources/node_resource.rb', line 12 def ssh @ssh end |
#validator_client ⇒ Object (readonly)
Returns the value of attribute validator_client.
10 11 12 |
# File 'lib/ridley/resources/node_resource.rb', line 10 def validator_client @validator_client end |
#validator_path ⇒ Object (readonly)
Returns the value of attribute validator_path.
9 10 11 |
# File 'lib/ridley/resources/node_resource.rb', line 9 def validator_path @validator_path end |
#winrm ⇒ Object (readonly)
Returns the value of attribute winrm.
13 14 15 |
# File 'lib/ridley/resources/node_resource.rb', line 13 def winrm @winrm end |
Instance Method Details
#bootstrap(host, options = {}) ⇒ HostConnector::Response
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ridley/resources/node_resource.rb', line 84 def bootstrap(host, = {}) = .reverse_merge( server_url: server_url, validator_path: validator_path, validator_client: validator_client, encrypted_data_bag_secret: encrypted_data_bag_secret, ssh: ssh, winrm: winrm, chef_version: chef_version ) host_commander.bootstrap(host, ) end |
#chef_run(host) ⇒ HostConnector::Response
Executes a Chef run using the best worker available for the given host.
104 105 106 |
# File 'lib/ridley/resources/node_resource.rb', line 104 def chef_run(host) host_commander.chef_client(host, ssh: ssh, winrm: winrm) end |
#merge_data(target, options = {}) ⇒ Ridley::NodeObject
Merges the given data with the the data of the target node on the remote
155 156 157 158 159 160 161 |
# File 'lib/ridley/resources/node_resource.rb', line 155 def merge_data(target, = {}) unless node = find(target) abort Errors::ResourceNotFound.new end update(node.merge_data()) end |
#put_secret(host) ⇒ HostConnector::Response
Puts a secret on the host using the best worker available for the given host.
114 115 116 |
# File 'lib/ridley/resources/node_resource.rb', line 114 def put_secret(host) host_commander.put_secret(host, encrypted_data_bag_secret, ssh: ssh, winrm: winrm) end |
#ruby_script(host, command_lines) ⇒ HostConnector::Response
Executes an arbitrary ruby script using the best worker available for the given host.
125 126 127 |
# File 'lib/ridley/resources/node_resource.rb', line 125 def ruby_script(host, command_lines) host_commander.ruby_script(host, command_lines, ssh: ssh, winrm: winrm) end |
#run(host, command) ⇒ Array<Symbol, HostConnector::Response> Also known as: execute_command
Executes the given command on a node using the best worker available for the given host.
136 137 138 |
# File 'lib/ridley/resources/node_resource.rb', line 136 def run(host, command) host_commander.run(host, command, ssh: ssh, winrm: winrm) end |
#uninstall_chef(host, options = {}) ⇒ HostConnector::Response
Uninstall Chef from a node
184 185 186 187 |
# File 'lib/ridley/resources/node_resource.rb', line 184 def uninstall_chef(host, = {}) = .reverse_merge(ssh: ssh, winrm: winrm) host_commander.uninstall_chef(host, ) end |