Class: Ridley::HostCommander
- Inherits:
-
Object
- Object
- Ridley::HostCommander
- Includes:
- Celluloid, Logging
- Defined in:
- lib/ridley-connectors/host_commander.rb
Constant Summary collapse
- DEFAULT_WINDOWS_CONNECTOR =
"winrm"
- DEFAULT_LINUX_CONNECTOR =
"ssh"
- VALID_CONNECTORS =
[ DEFAULT_WINDOWS_CONNECTOR, DEFAULT_LINUX_CONNECTOR ]
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, ...
Finds and returns the best HostConnector for a given host.
-
#initialize(connector_pool_size = nil) ⇒ 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.
-
#update_omnibus(host, options = {}) ⇒ HostConnector::Response
Update a node’s Omnibus installation of Chef.
Constructor Details
#initialize(connector_pool_size = nil) ⇒ HostCommander
Returns a new instance of HostCommander.
33 34 35 36 37 |
# File 'lib/ridley-connectors/host_commander.rb', line 33 def initialize(connector_pool_size=nil) connector_pool_size ||= 1 @connector_registry = Celluloid::Registry.new @connector_supervisor = ConnectorSupervisor.new_link(@connector_registry, connector_pool_size) end |
Instance Method Details
#bootstrap(host, options = {}) ⇒ HostConnector::Response
Bootstrap a node
80 81 82 |
# File 'lib/ridley-connectors/host_commander.rb', line 80 def bootstrap(host, = {}) execute(__method__, host, ) end |
#chef_client(host, options = {}) ⇒ HostConnector::Response
Perform a chef client run on a node
103 104 105 |
# File 'lib/ridley-connectors/host_commander.rb', line 103 def chef_client(host, = {}) execute(__method__, host, ) end |
#connector_for(host, options = {}) ⇒ HostConnector::SSH, ...
Finds and returns the best HostConnector for a given host
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/ridley-connectors/host_commander.rb', line 227 def connector_for(host, = {}) connector = [:connector].to_s if !VALID_CONNECTORS.include?(connector) log.debug { "Connector '#{connector}' is not one of #{VALID_CONNECTORS}. Determining connector..." } connector = nil end if (connector == DEFAULT_WINDOWS_CONNECTOR || connector.nil?) && winrm.connector_port_open?(host, ) winrm elsif (connector == DEFAULT_LINUX_CONNECTOR || connector.nil?) && ssh.connector_port_open?(host, ) ssh else nil end end |
#put_secret(host, secret, options = {}) ⇒ HostConnector::Response
Write your encrypted data bag secret on a node
128 129 130 |
# File 'lib/ridley-connectors/host_commander.rb', line 128 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
153 154 155 |
# File 'lib/ridley-connectors/host_commander.rb', line 153 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
59 60 61 |
# File 'lib/ridley-connectors/host_commander.rb', line 59 def run(host, command, = {}) execute(__method__, host, command, ) end |
#uninstall_chef(host, options = {}) ⇒ HostConnector::Response
Uninstall Chef from a node
180 181 182 |
# File 'lib/ridley-connectors/host_commander.rb', line 180 def uninstall_chef(host, = {}) execute(__method__, host, ) end |
#update_omnibus(host, options = {}) ⇒ HostConnector::Response
Update a node’s Omnibus installation of Chef
207 208 209 |
# File 'lib/ridley-connectors/host_commander.rb', line 207 def update_omnibus(host, = {}) execute(__method__, host, ) end |