Sha256: 6dc6ce882d5b4c5266f80ab2fd7da90c02d686a3441fc0eb8cc0d0b08ca39606

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

require 'rundock/operation/base'

module Rundock
  module Hook
    # You can use this sample as following yaml files for example.
    #
    # [hook.yml]
    # major_log:
    #   hook_type: file
    #   filepath: /var/log/rundock.log
    # minor_log:
    #   hook_type: file
    #   filepath: /tmp/rundock.log
    #
    # [scenario.yml]
    # - node: anyhost-01
    # command:
    #   - 'rm -f /tmp/aaa'
    # hook:
    #   - major_log
    #   - minor_log
    # - node: localhost
    # command:
    #   - 'echo aaa > /tmp/abc'
    # hook: all
    # ---
    # anyhost-01:
    #   host: 192.168.1.11
    #   ssh_opts:
    #     port: 22
    #     user: anyuser
    #     key:  ~/.ssh/id_rsa
    # ---
    class File < Base
      def hook(log_buffer, node_info)
        file = ::File.open(@contents[:filepath], 'w')
        file.puts("[hookname:#{@name} node:#{node_info[:host]}]")
        log_buffer.each do |log|
          file.puts("[\%5s:] %s%s\n" % [log.severity, ' ' * 2 * log.indent_depth, log.msg])
        end
        file.close
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rundock-0.4.8 lib/rundock/plugin/hook/file.rb
rundock-0.4.7 lib/rundock/plugin/hook/file.rb
rundock-0.4.6 lib/rundock/plugin/hook/file.rb
rundock-0.4.4 lib/rundock/plugin/hook/file.rb
rundock-0.4.3 lib/rundock/plugin/hook/file.rb
rundock-0.4.2 lib/rundock/plugin/hook/file.rb
rundock-0.4.1 lib/rundock/plugin/hook/file.rb
rundock-0.4.0 lib/rundock/plugin/hook/file.rb