rundock 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Rakefile +7 -1
- data/hooks_sample.yml +7 -0
- data/lib/rundock/attribute/node_attribute.rb +1 -0
- data/lib/rundock/builder/hook_builder.rb +46 -0
- data/lib/rundock/builder/operation_builder.rb +8 -3
- data/lib/rundock/cli.rb +3 -0
- data/lib/rundock/hook/base.rb +19 -0
- data/lib/rundock/hook_factory.rb +31 -0
- data/lib/rundock/logger.rb +27 -0
- data/lib/rundock/node.rb +16 -0
- data/lib/rundock/plugin/hook/file.rb +45 -0
- data/lib/rundock/runner.rb +1 -1
- data/lib/rundock/version.rb +1 -1
- data/lib/rundock.rb +3 -0
- data/scenario_sample.yml +4 -0
- data/spec/integration/hooks/all_file_hooks.yml +6 -0
- data/spec/integration/hooks/simple_file_hooks.yml +9 -0
- data/spec/integration/platforms/localhost/scenarios/all_file_hooks_scenario.yml +5 -0
- data/spec/integration/platforms/localhost/scenarios/simple_file_hooks_scenario.yml +15 -0
- data/spec/integration/recipes/file_hook_spec.rb +26 -0
- data/spec/integration/scenarios/all_file_hooks_scenario.yml +12 -0
- data/spec/integration/scenarios/simple_file_hooks_scenario.yml +16 -0
- metadata +14 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ac0d1b1d024e3fb776363046e50b0491d565bd14
         | 
| 4 | 
            +
              data.tar.gz: fcc471769968893cec01ad5448596f89a25a60c4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1ed1fa084c198d5ef541533a5b6dea968a9bdfef73b8fe952b50ded41587ac905eab7d1af64e92c31db8272083f2045e2ed4069b0eb72fc856dbfd225caaecd3
         | 
| 7 | 
            +
              data.tar.gz: aeddc0612d79caa97beb41d77e104085514fed0cc96dcbf298b4df8ab4045721ebb5f69068a0ffb0fed7085f2b3f992e9a08423067536540d169d02f4d52f3af
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | @@ -73,8 +73,14 @@ def do_rundock_scenarios(platform) | |
| 73 73 | 
             
                  default_ssh_opt = ''
         | 
| 74 74 | 
             
                end
         | 
| 75 75 |  | 
| 76 | 
            +
                if scenario =~ %r{^*scenarios/(.*_hooks)_scenario.yml$}
         | 
| 77 | 
            +
                  hooks_opt = " -k ./spec/integration/hooks/#{Regexp.last_match(1)}.yml"
         | 
| 78 | 
            +
                else
         | 
| 79 | 
            +
                  hooks_opt = ''
         | 
| 80 | 
            +
                end
         | 
| 81 | 
            +
             | 
| 76 82 | 
             
                execute('bundle exec exe/rundock' \
         | 
| 77 | 
            -
                   " do #{scenario}#{default_ssh_opt} -l debug", true)
         | 
| 83 | 
            +
                   " do #{scenario}#{default_ssh_opt}#{hooks_opt} -l debug", true)
         | 
| 78 84 | 
             
              end
         | 
| 79 85 | 
             
            end
         | 
| 80 86 |  | 
    
        data/hooks_sample.yml
    ADDED
    
    
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            require 'yaml'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Rundock
         | 
| 4 | 
            +
              module Builder
         | 
| 5 | 
            +
                class HookBuilder < Base
         | 
| 6 | 
            +
                  HookStructureError = Class.new(NotImplementedError)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def build(enables)
         | 
| 9 | 
            +
                    if enables.blank?
         | 
| 10 | 
            +
                      return []
         | 
| 11 | 
            +
                    elsif @options[:hooks] && FileTest.exist?(@options[:hooks])
         | 
| 12 | 
            +
                      hooks_file = @options[:hooks]
         | 
| 13 | 
            +
                    else
         | 
| 14 | 
            +
                      return []
         | 
| 15 | 
            +
                    end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                    build_from_file(hooks_file, enables)
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def build_from_attributes(attributes)
         | 
| 21 | 
            +
                    return [] unless attributes.key?(:enable_hooks)
         | 
| 22 | 
            +
                    build_from_file(attributes[:hooks], attributes[:enable_hooks])
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  private
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  def build_from_file(file, enables)
         | 
| 28 | 
            +
                    hooks = []
         | 
| 29 | 
            +
                    allow_all = enables.include?('all')
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    File.open(file) do |f|
         | 
| 32 | 
            +
                      YAML.load_documents(f) do |y|
         | 
| 33 | 
            +
                        y.each do |k, v|
         | 
| 34 | 
            +
                          raise HookStructureError if !v.is_a?(Hash) || !v.key?('hook_type')
         | 
| 35 | 
            +
                          next if !allow_all && enables.include?(k)
         | 
| 36 | 
            +
                          hook = Rundock::HookFactory.instance(v['hook_type']).create(k, v.deep_symbolize_keys)
         | 
| 37 | 
            +
                          hooks << hook
         | 
| 38 | 
            +
                        end
         | 
| 39 | 
            +
                      end
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    hooks
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
            end
         | 
| @@ -21,16 +21,19 @@ module Rundock | |
| 21 21 | 
             
                      n.deep_symbolize_keys.each do |k, v|
         | 
| 22 22 | 
             
                        if k == :node
         | 
| 23 23 | 
             
                          node_attribute.finalize_node
         | 
| 24 | 
            -
                           | 
| 25 | 
            -
                          backend =  | 
| 24 | 
            +
                          backend_builder = BackendBuilder.new(@options, v, node_info)
         | 
| 25 | 
            +
                          backend = backend_builder.build
         | 
| 26 26 |  | 
| 27 27 | 
             
                          node = Node.new(v, backend)
         | 
| 28 28 | 
             
                          node_attribute.nodename = v
         | 
| 29 | 
            -
                          scen.node_info[v.to_sym] = node_attribute.nodeinfo =  | 
| 29 | 
            +
                          scen.node_info[v.to_sym] = node_attribute.nodeinfo = backend_builder.parsed_options
         | 
| 30 30 |  | 
| 31 31 | 
             
                          if @options[:command]
         | 
| 32 32 | 
             
                            node.add_operation(build_cli_command_operation(@options[:command], node_attribute, @options))
         | 
| 33 33 | 
             
                          end
         | 
| 34 | 
            +
                        elsif k == :hook
         | 
| 35 | 
            +
                          node_attribute.enable_hooks = Array(v)
         | 
| 36 | 
            +
                          node.hooks = HookBuilder.new(@options).build(Array(v)) if node
         | 
| 34 37 | 
             
                        else
         | 
| 35 38 |  | 
| 36 39 | 
             
                          next unless node
         | 
| @@ -47,6 +50,7 @@ module Rundock | |
| 47 50 |  | 
| 48 51 | 
             
                  def build_task(tasks, backend, node_attribute)
         | 
| 49 52 | 
             
                    node = Node.new(node_attribute.nodename, backend)
         | 
| 53 | 
            +
                    node.hooks = HookBuilder.new(nil).build_from_attributes(node_attribute.nodeinfo)
         | 
| 50 54 | 
             
                    scen = Scenario.new
         | 
| 51 55 |  | 
| 52 56 | 
             
                    tasks.each do |k, v|
         | 
| @@ -64,6 +68,7 @@ module Rundock | |
| 64 68 | 
             
                    @options[:host].split(',').each do |host|
         | 
| 65 69 | 
             
                      backend = BackendBuilder.new(@options, host, nil).build
         | 
| 66 70 | 
             
                      node = Node.new(host, backend)
         | 
| 71 | 
            +
                      node.hooks = HookBuilder.new(@options).build(['all'])
         | 
| 67 72 | 
             
                      node.add_operation(
         | 
| 68 73 | 
             
                        build_cli_command_operation(@options[:command], Rundock::Attribute::NodeAttribute.new, @options))
         | 
| 69 74 | 
             
                      scen.nodes.push(node)
         | 
    
        data/lib/rundock/cli.rb
    CHANGED
    
    | @@ -6,6 +6,7 @@ module Rundock | |
| 6 6 | 
             
                DEFAULT_SCENARIO_FILE_PATH = './scenario.yml'
         | 
| 7 7 | 
             
                DEFAULT_SSH_OPTIONS_DEFAULT_FILE_PATH = './default_ssh.yml'
         | 
| 8 8 | 
             
                DEFAULT_HOSTGROUP_FILE_PATH = './hostgroup.yml'
         | 
| 9 | 
            +
                DEFAULT_HOOKS_FILE_PATH = './hooks.yml'
         | 
| 9 10 |  | 
| 10 11 | 
             
                class_option :log_level, type: :string, aliases: ['-l'], default: 'info'
         | 
| 11 12 | 
             
                class_option :color, type: :boolean, default: true
         | 
| @@ -27,6 +28,7 @@ module Rundock | |
| 27 28 | 
             
                desc 'do [SCENARIO] [options]', 'Run rundock from scenario file'
         | 
| 28 29 | 
             
                option :sudo, type: :boolean, default: false
         | 
| 29 30 | 
             
                option :default_ssh_opts, type: :string, aliases: ['-d'], default: DEFAULT_SSH_OPTIONS_DEFAULT_FILE_PATH
         | 
| 31 | 
            +
                option :hooks, type: :string, aliases: ['-k'], default: DEFAULT_HOOKS_FILE_PATH
         | 
| 30 32 | 
             
                option :run_anyway, type: :boolean, default: false
         | 
| 31 33 | 
             
                option :dry_run, type: :boolean, aliases: ['-n']
         | 
| 32 34 | 
             
                def do(*scenario_file_path)
         | 
| @@ -39,6 +41,7 @@ module Rundock | |
| 39 41 | 
             
                desc 'ssh [options]', 'Run rundock ssh with various options'
         | 
| 40 42 | 
             
                option :command, type: :string, aliases: ['-c']
         | 
| 41 43 | 
             
                option :default_ssh_opts, type: :string, aliases: ['-d'], default: DEFAULT_SSH_OPTIONS_DEFAULT_FILE_PATH
         | 
| 44 | 
            +
                option :hooks, type: :string, aliases: ['-k'], default: DEFAULT_HOOKS_FILE_PATH
         | 
| 42 45 | 
             
                option :host, type: :string, aliases: ['-h'], banner: 'You can specify comma separated hosts.[ex: host1,host2,..]'
         | 
| 43 46 | 
             
                option :hostgroup, type: :string, aliases: ['-g']
         | 
| 44 47 | 
             
                option :user, type: :string, aliases: ['-u']
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            module Rundock
         | 
| 2 | 
            +
              module Hook
         | 
| 3 | 
            +
                class Base
         | 
| 4 | 
            +
                  HookNotImplementedError = Class.new(NotImplementedError)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  attr_reader :name
         | 
| 7 | 
            +
                  attr_reader :contents
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def initialize(name, contents = {})
         | 
| 10 | 
            +
                    @name = name
         | 
| 11 | 
            +
                    @contents = contents
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def hook(log_buffer = [], node_info = {})
         | 
| 15 | 
            +
                    raise HookNotImplementedError
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            module Rundock
         | 
| 2 | 
            +
              class HookFactory
         | 
| 3 | 
            +
                HookNotImplementedError = Class.new(NotImplementedError)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def self.instance(type)
         | 
| 6 | 
            +
                  self.new(type)
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def initialize(type)
         | 
| 10 | 
            +
                  @type = type
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def create(name, attributes)
         | 
| 14 | 
            +
                  klass = "Rundock::Hook::#{@type.to_s.to_camel_case}"
         | 
| 15 | 
            +
                  Logger.debug("initialize #{klass} hook")
         | 
| 16 | 
            +
                  raise HookNotImplementedError unless Rundock::Hook::Base.subclasses.map(&:to_s).include?(klass)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  obj = nil
         | 
| 19 | 
            +
                  klass.split('::').map do |k|
         | 
| 20 | 
            +
                    if obj.nil?
         | 
| 21 | 
            +
                      obj = Kernel.const_get(k)
         | 
| 22 | 
            +
                    else
         | 
| 23 | 
            +
                      obj = obj.const_get(k)
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  hook = obj.new(name, attributes)
         | 
| 28 | 
            +
                  hook
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
    
        data/lib/rundock/logger.rb
    CHANGED
    
    | @@ -4,15 +4,34 @@ require 'ansi/code' | |
| 4 4 |  | 
| 5 5 | 
             
            module Rundock
         | 
| 6 6 | 
             
              module Logger
         | 
| 7 | 
            +
                class LogEntity
         | 
| 8 | 
            +
                  attr_accessor :severity
         | 
| 9 | 
            +
                  attr_accessor :datetime
         | 
| 10 | 
            +
                  attr_accessor :progname
         | 
| 11 | 
            +
                  attr_accessor :msg
         | 
| 12 | 
            +
                  attr_accessor :indent_depth
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def initialize(severity, datetime, progname, msg, indent_depth)
         | 
| 15 | 
            +
                    @severity = severity
         | 
| 16 | 
            +
                    @datetime = datetime
         | 
| 17 | 
            +
                    @progname = progname
         | 
| 18 | 
            +
                    @msg      = msg
         | 
| 19 | 
            +
                    @indent_depth = indent_depth
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 7 23 | 
             
                class Formatter
         | 
| 8 24 | 
             
                  attr_accessor :colored
         | 
| 9 25 | 
             
                  attr_accessor :indent_depth
         | 
| 10 26 | 
             
                  attr_accessor :color
         | 
| 11 27 | 
             
                  attr_accessor :show_header
         | 
| 28 | 
            +
                  attr_accessor :onrec
         | 
| 29 | 
            +
                  attr_accessor :buffer
         | 
| 12 30 |  | 
| 13 31 | 
             
                  def initialize(*args)
         | 
| 14 32 | 
             
                    super
         | 
| 15 33 | 
             
                    @indent_depth = 0
         | 
| 34 | 
            +
                    @buffer = []
         | 
| 16 35 | 
             
                  end
         | 
| 17 36 |  | 
| 18 37 | 
             
                  def call(severity, datetime, progname, msg)
         | 
| @@ -22,6 +41,8 @@ module Rundock | |
| 22 41 | 
             
                      out = "%s\n" % [msg2str(msg)]
         | 
| 23 42 | 
             
                    end
         | 
| 24 43 |  | 
| 44 | 
            +
                    @buffer << LogEntity.new(severity, datetime, progname, msg, indent_depth)
         | 
| 45 | 
            +
             | 
| 25 46 | 
             
                    if colored
         | 
| 26 47 | 
             
                      colorize(out, severity)
         | 
| 27 48 | 
             
                    else
         | 
| @@ -52,6 +73,12 @@ module Rundock | |
| 52 73 | 
             
                    @color = prev_color
         | 
| 53 74 | 
             
                  end
         | 
| 54 75 |  | 
| 76 | 
            +
                  def flush
         | 
| 77 | 
            +
                    ret = @buffer.dup
         | 
| 78 | 
            +
                    @buffer.clear
         | 
| 79 | 
            +
                    ret
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
             | 
| 55 82 | 
             
                  private
         | 
| 56 83 |  | 
| 57 84 | 
             
                  def msg2str(msg)
         | 
    
        data/lib/rundock/node.rb
    CHANGED
    
    | @@ -5,11 +5,13 @@ module Rundock | |
| 5 5 | 
             
                attr_reader :name
         | 
| 6 6 | 
             
                attr_reader :operations
         | 
| 7 7 | 
             
                attr_reader :backend
         | 
| 8 | 
            +
                attr_accessor :hooks
         | 
| 8 9 |  | 
| 9 10 | 
             
                def initialize(name, backend)
         | 
| 10 11 | 
             
                  @name = name
         | 
| 11 12 | 
             
                  @backend = backend
         | 
| 12 13 | 
             
                  @operations = []
         | 
| 14 | 
            +
                  @hooks = []
         | 
| 13 15 | 
             
                end
         | 
| 14 16 |  | 
| 15 17 | 
             
                def add_operation(ope)
         | 
| @@ -24,15 +26,29 @@ module Rundock | |
| 24 26 | 
             
                end
         | 
| 25 27 |  | 
| 26 28 | 
             
                def run
         | 
| 29 | 
            +
                  Logger.formatter.onrec = true
         | 
| 27 30 | 
             
                  Logger.debug("run node: #{@name}")
         | 
| 28 31 | 
             
                  if @operations.blank?
         | 
| 29 32 | 
             
                    Logger.warn("no operation running: #{@name}")
         | 
| 30 33 | 
             
                    return
         | 
| 31 34 | 
             
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  nodeinfo = nil
         | 
| 37 | 
            +
             | 
| 32 38 | 
             
                  @operations.each do |ope|
         | 
| 33 39 | 
             
                    Logger.debug("run operation: #{ope.class}")
         | 
| 40 | 
            +
                    nodeinfo = ope.attributes[:nodeinfo] if nodeinfo.nil?
         | 
| 34 41 | 
             
                    ope.run(@backend, ope.attributes)
         | 
| 35 42 | 
             
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  log_buffer = Logger.formatter.flush unless Logger.formatter.buffer.empty?
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  @hooks.each do |h|
         | 
| 47 | 
            +
                    Logger.debug("run hook: #{h.name}")
         | 
| 48 | 
            +
                    h.hook(log_buffer, nodeinfo)
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                  Logger.formatter.onrec = false
         | 
| 36 52 | 
             
                end
         | 
| 37 53 | 
             
              end
         | 
| 38 54 | 
             
            end
         | 
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            require 'rundock/operation/base'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Rundock
         | 
| 4 | 
            +
              module Hook
         | 
| 5 | 
            +
                # You can use this sample as following yaml files for example.
         | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                # [hook.yml]
         | 
| 8 | 
            +
                # major_log:
         | 
| 9 | 
            +
                #   hook_type: file
         | 
| 10 | 
            +
                #   filepath: /var/log/rundock.log
         | 
| 11 | 
            +
                # minor_log:
         | 
| 12 | 
            +
                #   hook_type: file
         | 
| 13 | 
            +
                #   filepath: /tmp/rundock.log
         | 
| 14 | 
            +
                #
         | 
| 15 | 
            +
                # [scenario.yml]
         | 
| 16 | 
            +
                # - node: anyhost-01
         | 
| 17 | 
            +
                # command:
         | 
| 18 | 
            +
                #   - 'rm -f /tmp/aaa'
         | 
| 19 | 
            +
                # hook:
         | 
| 20 | 
            +
                #   - major_log
         | 
| 21 | 
            +
                #   - minor_log
         | 
| 22 | 
            +
                # - node: localhost
         | 
| 23 | 
            +
                # command:
         | 
| 24 | 
            +
                #   - 'echo aaa > /tmp/abc'
         | 
| 25 | 
            +
                # hook: all
         | 
| 26 | 
            +
                # ---
         | 
| 27 | 
            +
                # anyhost-01:
         | 
| 28 | 
            +
                #   host: 192.168.1.11
         | 
| 29 | 
            +
                #   ssh_opts:
         | 
| 30 | 
            +
                #     port: 22
         | 
| 31 | 
            +
                #     user: anyuser
         | 
| 32 | 
            +
                #     key:  ~/.ssh/id_rsa
         | 
| 33 | 
            +
                # ---
         | 
| 34 | 
            +
                class File < Base
         | 
| 35 | 
            +
                  def hook(log_buffer, node_info)
         | 
| 36 | 
            +
                    file = ::File.open(@contents[:filepath], 'w')
         | 
| 37 | 
            +
                    file.puts("[hookname:#{@name} node:#{node_info[:host]}]")
         | 
| 38 | 
            +
                    log_buffer.each do |log|
         | 
| 39 | 
            +
                      file.puts("[\%5s:] %s%s\n" % [log.severity, ' ' * 2 * log.indent_depth, log.msg])
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
                    file.close
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
            end
         | 
    
        data/lib/rundock/runner.rb
    CHANGED
    
    | @@ -77,7 +77,7 @@ module Rundock | |
| 77 77 | 
             
                      next if g !~ /^(rundock-plugin-#{plugin})-/
         | 
| 78 78 | 
             
                      next if Gem::Specification.find_by_name(g).nil?
         | 
| 79 79 | 
             
                      Logger.debug("Loading rundock plugin: #{g}")
         | 
| 80 | 
            -
                      libdir = "#{Gem::Specification.find_by_name(g).full_gem_path}/lib/#{Regexp.last_match( | 
| 80 | 
            +
                      libdir = "#{Gem::Specification.find_by_name(g).full_gem_path}/lib/#{Regexp.last_match(1).gsub(/-/, '/')}"
         | 
| 81 81 | 
             
                      Dir.glob("#{libdir}/*.rb").each do |f|
         | 
| 82 82 | 
             
                        require f.gsub(/.rb$/, '')
         | 
| 83 83 | 
             
                      end
         | 
    
        data/lib/rundock/version.rb
    CHANGED
    
    
    
        data/lib/rundock.rb
    CHANGED
    
    | @@ -6,6 +6,8 @@ require 'rundock/operation/base' | |
| 6 6 | 
             
            require 'rundock/operation/task'
         | 
| 7 7 | 
             
            require 'rundock/operation/command'
         | 
| 8 8 | 
             
            require 'rundock/operation_factory'
         | 
| 9 | 
            +
            require 'rundock/hook_factory'
         | 
| 10 | 
            +
            require 'rundock/hook/base'
         | 
| 9 11 | 
             
            require 'rundock/node'
         | 
| 10 12 | 
             
            require 'rundock/attribute/base'
         | 
| 11 13 | 
             
            require 'rundock/attribute/node_attribute'
         | 
| @@ -14,6 +16,7 @@ require 'rundock/backend' | |
| 14 16 | 
             
            require 'rundock/builder/base'
         | 
| 15 17 | 
             
            require 'rundock/builder/default_ssh_builder'
         | 
| 16 18 | 
             
            require 'rundock/builder/backend_builder'
         | 
| 19 | 
            +
            require 'rundock/builder/hook_builder'
         | 
| 17 20 | 
             
            require 'rundock/builder/operation_builder'
         | 
| 18 21 | 
             
            require 'rundock/builder/scenario_builder'
         | 
| 19 22 | 
             
            require 'rundock/runner'
         | 
    
        data/scenario_sample.yml
    CHANGED
    
    | @@ -34,6 +34,9 @@ | |
| 34 34 | 
             
              command:
         | 
| 35 35 | 
             
                - "hostname"
         | 
| 36 36 | 
             
                - "uname -a"
         | 
| 37 | 
            +
              hook:
         | 
| 38 | 
            +
                - mail
         | 
| 39 | 
            +
                - file
         | 
| 37 40 | 
             
            - node: anyhost-01
         | 
| 38 41 | 
             
              task:
         | 
| 39 42 | 
             
                - echo_platform
         | 
| @@ -44,6 +47,7 @@ | |
| 44 47 | 
             
                - errexit: false
         | 
| 45 48 | 
             
                - "rm /tmp/safetyfile"
         | 
| 46 49 | 
             
                - "ls -1 /tmp"
         | 
| 50 | 
            +
              hook: all
         | 
| 47 51 | 
             
            ---
         | 
| 48 52 | 
             
            anyhost-01:
         | 
| 49 53 | 
             
              host: 192.168.1.11
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            file_one:
         | 
| 2 | 
            +
              hook_type: file
         | 
| 3 | 
            +
              filepath: /var/tmp/hello_rundock_from_file_hook_one_scenario
         | 
| 4 | 
            +
            file_array_1:
         | 
| 5 | 
            +
              hook_type: file
         | 
| 6 | 
            +
              filepath: /var/tmp/hello_rundock_from_file_hook_array_1_scenario
         | 
| 7 | 
            +
            file_array_2:
         | 
| 8 | 
            +
              hook_type: file
         | 
| 9 | 
            +
              filepath: /var/tmp/hello_rundock_from_file_hook_array_2_scenario
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            - node: localhost
         | 
| 2 | 
            +
              command:
         | 
| 3 | 
            +
                - "rm -f /var/tmp/hello_rundock_from_file_hook_one_scenario"
         | 
| 4 | 
            +
                - "rm -f /var/tmp/hello_rundock_from_file_hook_array_1_scenario"
         | 
| 5 | 
            +
                - "rm -f /var/tmp/hello_rundock_from_file_hook_array_2_scenario"
         | 
| 6 | 
            +
              hook: file_one
         | 
| 7 | 
            +
            - node: anyhost-01
         | 
| 8 | 
            +
              command:
         | 
| 9 | 
            +
                - "echo aaa"
         | 
| 10 | 
            +
              hook:
         | 
| 11 | 
            +
                - file_array_1
         | 
| 12 | 
            +
                - file_array_2
         | 
| 13 | 
            +
            ---
         | 
| 14 | 
            +
            anyhost-01:
         | 
| 15 | 
            +
              host: localhost
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe file('/var/tmp/hello_rundock_from_file_hook_one_scenario') do
         | 
| 4 | 
            +
              it { should be_file }
         | 
| 5 | 
            +
              its(:content) { should match(/hookname:file_one /) }
         | 
| 6 | 
            +
            end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            describe file('/var/tmp/hello_rundock_from_file_hook_array_1_scenario') do
         | 
| 9 | 
            +
              it { should be_file }
         | 
| 10 | 
            +
              its(:content) { should match(/hookname:file_array_1 /) }
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            describe file('/var/tmp/hello_rundock_from_file_hook_array_2_scenario') do
         | 
| 14 | 
            +
              it { should be_file }
         | 
| 15 | 
            +
              its(:content) { should match(/hookname:file_array_2 /) }
         | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            describe file('/var/tmp/hello_rundock_from_file_hook_all_1_scenario') do
         | 
| 19 | 
            +
              it { should be_file }
         | 
| 20 | 
            +
              its(:content) { should match(/hookname:file_all_1 /) }
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            describe file('/var/tmp/hello_rundock_from_file_hook_all_2_scenario') do
         | 
| 24 | 
            +
              it { should be_file }
         | 
| 25 | 
            +
              its(:content) { should match(/hookname:file_all_2 /) }
         | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            - node: anyhost-01
         | 
| 2 | 
            +
              command:
         | 
| 3 | 
            +
                - "echo 'hookname:file_all_1 ' > /var/tmp/hello_rundock_from_file_hook_all_1_scenario"
         | 
| 4 | 
            +
                - "echo 'hookname:file_all_2 ' > /var/tmp/hello_rundock_from_file_hook_all_2_scenario"
         | 
| 5 | 
            +
              hook: all
         | 
| 6 | 
            +
            ---
         | 
| 7 | 
            +
            anyhost-01:
         | 
| 8 | 
            +
              host: 172.17.42.1
         | 
| 9 | 
            +
              ssh_opts:
         | 
| 10 | 
            +
                port: 22222
         | 
| 11 | 
            +
                user: tester
         | 
| 12 | 
            +
                key: "<replaced_by_platforms>"
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            - node: anyhost-01
         | 
| 2 | 
            +
              command:
         | 
| 3 | 
            +
                - "echo 'hookname:file_one ' > /var/tmp/hello_rundock_from_file_hook_one_scenario"
         | 
| 4 | 
            +
                - "echo 'hookname:file_array_1 ' > /var/tmp/hello_rundock_from_file_hook_array_1_scenario"
         | 
| 5 | 
            +
                - "echo 'hookname:file_array_2 ' > /var/tmp/hello_rundock_from_file_hook_array_2_scenario"
         | 
| 6 | 
            +
              hook:
         | 
| 7 | 
            +
                - file_one
         | 
| 8 | 
            +
                - file_array_1
         | 
| 9 | 
            +
                - file_array_2
         | 
| 10 | 
            +
            ---
         | 
| 11 | 
            +
            anyhost-01:
         | 
| 12 | 
            +
              host: 172.17.42.1
         | 
| 13 | 
            +
              ssh_opts:
         | 
| 14 | 
            +
                port: 22222
         | 
| 15 | 
            +
                user: tester
         | 
| 16 | 
            +
                key: "<replaced_by_platforms>"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rundock
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - hiracy
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-08- | 
| 11 | 
            +
            date: 2015-08-20 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -150,6 +150,7 @@ files: | |
| 150 150 | 
             
            - circle.yml
         | 
| 151 151 | 
             
            - default_ssh.yml
         | 
| 152 152 | 
             
            - exe/rundock
         | 
| 153 | 
            +
            - hooks_sample.yml
         | 
| 153 154 | 
             
            - lib/rundock.rb
         | 
| 154 155 | 
             
            - lib/rundock/attribute/base.rb
         | 
| 155 156 | 
             
            - lib/rundock/attribute/node_attribute.rb
         | 
| @@ -157,17 +158,21 @@ files: | |
| 157 158 | 
             
            - lib/rundock/builder/backend_builder.rb
         | 
| 158 159 | 
             
            - lib/rundock/builder/base.rb
         | 
| 159 160 | 
             
            - lib/rundock/builder/default_ssh_builder.rb
         | 
| 161 | 
            +
            - lib/rundock/builder/hook_builder.rb
         | 
| 160 162 | 
             
            - lib/rundock/builder/operation_builder.rb
         | 
| 161 163 | 
             
            - lib/rundock/builder/scenario_builder.rb
         | 
| 162 164 | 
             
            - lib/rundock/cli.rb
         | 
| 163 165 | 
             
            - lib/rundock/ext/hash.rb
         | 
| 164 166 | 
             
            - lib/rundock/ext/object/blank.rb
         | 
| 167 | 
            +
            - lib/rundock/hook/base.rb
         | 
| 168 | 
            +
            - lib/rundock/hook_factory.rb
         | 
| 165 169 | 
             
            - lib/rundock/logger.rb
         | 
| 166 170 | 
             
            - lib/rundock/node.rb
         | 
| 167 171 | 
             
            - lib/rundock/operation/base.rb
         | 
| 168 172 | 
             
            - lib/rundock/operation/command.rb
         | 
| 169 173 | 
             
            - lib/rundock/operation/task.rb
         | 
| 170 174 | 
             
            - lib/rundock/operation_factory.rb
         | 
| 175 | 
            +
            - lib/rundock/plugin/hook/file.rb
         | 
| 171 176 | 
             
            - lib/rundock/plugin/operation/deploy.rb
         | 
| 172 177 | 
             
            - lib/rundock/plugin/operation/host_inventory.rb
         | 
| 173 178 | 
             
            - lib/rundock/plugin/operation/sample_operation.rb
         | 
| @@ -177,19 +182,26 @@ files: | |
| 177 182 | 
             
            - rundock.gemspec
         | 
| 178 183 | 
             
            - scenario_sample.yml
         | 
| 179 184 | 
             
            - spec/integration/groups/simple_host_group.yml
         | 
| 185 | 
            +
            - spec/integration/hooks/all_file_hooks.yml
         | 
| 186 | 
            +
            - spec/integration/hooks/simple_file_hooks.yml
         | 
| 180 187 | 
             
            - spec/integration/platforms/centos6/Dockerfile
         | 
| 181 188 | 
             
            - spec/integration/platforms/centos6/setup.sh
         | 
| 189 | 
            +
            - spec/integration/platforms/localhost/scenarios/all_file_hooks_scenario.yml
         | 
| 182 190 | 
             
            - spec/integration/platforms/localhost/scenarios/deploy_scenario.yml
         | 
| 183 191 | 
             
            - spec/integration/platforms/localhost/scenarios/run_anyway_scenario.yml
         | 
| 184 192 | 
             
            - spec/integration/platforms/localhost/scenarios/simple_echo_scenario.yml
         | 
| 193 | 
            +
            - spec/integration/platforms/localhost/scenarios/simple_file_hooks_scenario.yml
         | 
| 185 194 | 
             
            - spec/integration/platforms/localhost/scenarios/simple_plugin_scenario.yml
         | 
| 186 195 | 
             
            - spec/integration/platforms/localhost/scenarios/use_default_ssh_scenario.yml
         | 
| 187 196 | 
             
            - spec/integration/recipes/deploy_spec.rb
         | 
| 197 | 
            +
            - spec/integration/recipes/file_hook_spec.rb
         | 
| 188 198 | 
             
            - spec/integration/recipes/simple_echo_scenario_spec.rb
         | 
| 189 199 | 
             
            - spec/integration/recipes/simple_echo_spec.rb
         | 
| 190 200 | 
             
            - spec/integration/recipes/simple_plugin_scenario_spec.rb
         | 
| 201 | 
            +
            - spec/integration/scenarios/all_file_hooks_scenario.yml
         | 
| 191 202 | 
             
            - spec/integration/scenarios/deploy_scenario.yml
         | 
| 192 203 | 
             
            - spec/integration/scenarios/simple_echo_scenario.yml
         | 
| 204 | 
            +
            - spec/integration/scenarios/simple_file_hooks_scenario.yml
         | 
| 193 205 | 
             
            - spec/integration/scenarios/simple_plugin_scenario.yml
         | 
| 194 206 | 
             
            - spec/integration/scenarios/use_default_ssh_scenario.yml
         | 
| 195 207 | 
             
            - spec/integration/spec_helper.rb
         |