Sha256: 5a10cb293aaae0ecd06c1fa567526b2ead6741cfd53b482144a44136cc224957

Contents?: true

Size: 993 Bytes

Versions: 35

Compression:

Stored size: 993 Bytes

Contents

require 'rundock/operation/base'

module Rundock
  module Operation
    # 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
    # ---
    class SampleOperation < Base
      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
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
rundock-1.0.4 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.0.2 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.0.1 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.0.0 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.5.8 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.5.7 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.5.4 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.5.3 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.5.2 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.5.0 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.4.16 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.4.15 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.4.14 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.4.13 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.4.12 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.4.11 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.4.10 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.4.8 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.4.7 lib/rundock/plugin/operation/sample_operation.rb
rundock-0.4.6 lib/rundock/plugin/operation/sample_operation.rb