Class: Ridley::HostCommander
- Inherits:
-
Object
- Object
- Ridley::HostCommander
- Includes:
- Celluloid, Logging
- Defined in:
- lib/ridley/host_commander.rb
Constant Summary collapse
- PORT_CHECK_TIMEOUT =
3
Instance Method Summary collapse
-
#bootstrap(host, options = {}) ⇒ HostConnector::Response
Bootstrap a node.
-
#chef_client(host, options = {}) ⇒ HostConnector::Response
Perform a chef client run on a node.
-
#connector_for(host, options = {}) ⇒ HostConnector::SSH, HostConnector::WinRM
Finds and returns the best HostConnector for a given host.
-
#initialize ⇒ HostCommander
constructor
A new instance of HostCommander.
-
#put_secret(host, secret, options = {}) ⇒ HostConnector::Response
Write your encrypted data bag secret on a node.
-
#ruby_script(host, command_lines, options = {}) ⇒ HostConnector::Response
Execute line(s) of Ruby code on a node using Chef’s embedded Ruby.
-
#run(host, command, options = {}) ⇒ HostConnector::Response
Execute a shell command on a node.
-
#uninstall_chef(host, options = {}) ⇒ HostConnector::Response
Uninstall Chef from a node.
Methods included from Logging
Constructor Details
#initialize ⇒ HostCommander
Returns a new instance of HostCommander.
19 20 21 22 |
# File 'lib/ridley/host_commander.rb', line 19 def initialize @connector_registry = Celluloid::Registry.new @connector_supervisor = ConnectorSupervisor.new_link(@connector_registry) end |
Instance Method Details
#bootstrap(host, options = {}) ⇒ HostConnector::Response
Bootstrap a node
63 64 65 |
# File 'lib/ridley/host_commander.rb', line 63 def bootstrap(host, = {}) execute(__method__, host, ) end |
#chef_client(host, options = {}) ⇒ HostConnector::Response
Perform a chef client run on a node
84 85 86 |
# File 'lib/ridley/host_commander.rb', line 84 def chef_client(host, = {}) execute(__method__, host, ) end |
#connector_for(host, options = {}) ⇒ HostConnector::SSH, HostConnector::WinRM
Finds and returns the best HostConnector for a given host
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/ridley/host_commander.rb', line 172 def connector_for(host, = {}) = .reverse_merge(ssh: Hash.new, winrm: Hash.new) [:ssh][:port] ||= HostConnector::SSH::DEFAULT_PORT [:winrm][:port] ||= HostConnector::WinRM::DEFAULT_PORT if connector_port_open?(host, [:winrm][:port]) .delete(:ssh) winrm elsif connector_port_open?(host, [:ssh][:port], [:ssh][:timeout]) .delete(:winrm) ssh else raise Errors::HostConnectionError, "No connector ports open on '#{host}'" end end |
#put_secret(host, secret, options = {}) ⇒ HostConnector::Response
Write your encrypted data bag secret on a node
107 108 109 |
# File 'lib/ridley/host_commander.rb', line 107 def put_secret(host, secret, = {}) execute(__method__, host, secret, ) end |
#ruby_script(host, command_lines, options = {}) ⇒ HostConnector::Response
Execute line(s) of Ruby code on a node using Chef’s embedded Ruby
130 131 132 |
# File 'lib/ridley/host_commander.rb', line 130 def ruby_script(host, command_lines, = {}) execute(__method__, host, command_lines, ) end |
#run(host, command, options = {}) ⇒ HostConnector::Response
Execute a shell command on a node
42 43 44 |
# File 'lib/ridley/host_commander.rb', line 42 def run(host, command, = {}) execute(__method__, host, command, ) end |
#uninstall_chef(host, options = {}) ⇒ HostConnector::Response
Uninstall Chef from a node
155 156 157 |
# File 'lib/ridley/host_commander.rb', line 155 def uninstall_chef(host, = {}) execute(__method__, host, ) end |