Sha256: c57061f987f0c281ed9340db757d3fd1b43eb3aac105886bb0303a57739a2bbf

Contents?: true

Size: 997 Bytes

Versions: 14

Compression:

Stored size: 997 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

        logging("do #{cmd}#{args_line}", 'info')
        result = backend.run_command("#{cmd}#{args_line}")
        Logger.info(result.stdout)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rundock-1.2.1 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.2.0 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.1.7 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.1.6 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.1.5 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.1.4 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.1.3 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.1.2 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.1.1 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.1.0 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.0.8 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.0.7 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.0.6 lib/rundock/plugin/operation/sample_operation.rb
rundock-1.0.5 lib/rundock/plugin/operation/sample_operation.rb