Class: Rundock::Operation::SampleOperation
- Defined in:
- lib/rundock/plugin/operation/sample_operation.rb
Overview
You can use this sample as following scenario.yml for example.
-
node: anyhost-01
sample_operation:
- cmd: 'ls ~'
all: true
anyhost-01:
host: 192.168.1.11
ssh_opts:
port: 22
user: anyuser
key: ~/.ssh/id_rsa
Constant Summary
Constants inherited from Base
Base::OperationNotImplementedError
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Rundock::Operation::Base
Instance Method Details
#run(backend, attributes) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rundock/plugin/operation/sample_operation.rb', line 20 def run(backend, attributes) operation = attributes[:sample_operation][0] cmd = '' args_line = '' operation.each do |k, v| if k == :cmd cmd = v next end if v.is_a?(TrueClass) args_line << " --#{k}" elsif v.is_a?(String) args_line << " --#{k} #{v}" end end Logger.info("do #{cmd}#{args_line}") result = backend.run_command("#{cmd}#{args_line}") Logger.info(result.stdout) end |