diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/oxidized/hook/exec.rb | 2 | ||||
| -rw-r--r-- | lib/oxidized/node.rb | 3 | ||||
| -rw-r--r-- | lib/oxidized/output/file.rb | 3 | ||||
| -rw-r--r-- | lib/oxidized/output/git.rb | 7 | ||||
| -rw-r--r-- | lib/oxidized/worker.rb | 6 | 
5 files changed, 16 insertions, 5 deletions
| diff --git a/lib/oxidized/hook/exec.rb b/lib/oxidized/hook/exec.rb index af2aeb1..58d6fd5 100644 --- a/lib/oxidized/hook/exec.rb +++ b/lib/oxidized/hook/exec.rb @@ -71,6 +71,8 @@ class Exec < Oxidized::Hook          "OX_NODE_MSG" => ctx.node.msg.to_s,          "OX_NODE_GROUP" => ctx.node.group.to_s,          "OX_EVENT" => ctx.event.to_s, +        "OX_REPO_COMMITREF" => ctx.commitref.to_s, +        "OX_REPO_NAME" => ctx.node.repo.to_s,        )      end      if ctx.job diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index c847416..df5b830 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -5,7 +5,7 @@ module Oxidized    class MethodNotFound < OxidizedError; end    class ModelNotFound  < OxidizedError; end    class Node -    attr_reader :name, :ip, :model, :input, :output, :group, :auth, :prompt, :vars, :last +    attr_reader :name, :ip, :model, :input, :output, :group, :auth, :prompt, :vars, :last, :repo      attr_accessor :running, :user, :msg, :from, :stats, :retry      alias :running? :running      def initialize opt @@ -24,6 +24,7 @@ module Oxidized        @vars           = opt[:vars]        @stats          = Stats.new        @retry          = 0 +      @repo           = CFG.output.git.repo        # model instance needs to access node instance        @model.node = self diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb index d1a8c17..eb915c3 100644 --- a/lib/oxidized/output/file.rb +++ b/lib/oxidized/output/file.rb @@ -2,6 +2,8 @@ module Oxidized  class OxidizedFile < Output    require 'fileutils' +  attr_reader :commitref +    def initialize      @cfg = CFG.output.file    end @@ -22,6 +24,7 @@ class OxidizedFile < Output      FileUtils.mkdir_p file      file = File.join file, node      open(file, 'w') { |fh| fh.write outputs.to_cfg } +    @commitref = file    end    def fetch node, group diff --git a/lib/oxidized/output/git.rb b/lib/oxidized/output/git.rb index 3757cfc..fff3941 100644 --- a/lib/oxidized/output/git.rb +++ b/lib/oxidized/output/git.rb @@ -7,6 +7,8 @@ class Git < Output      raise OxidizedError, 'rugged not found: sudo gem install rugged'    end +  attr_reader :commitref +    def initialize      @cfg = CFG.output.git    end @@ -27,6 +29,7 @@ class Git < Output      @user  = (opt[:user]  or @cfg.user)      @email = (opt[:email] or @cfg.email)      @opt   = opt +    @commitref = nil      repo   = @cfg.repo      outputs.types.each do |type| @@ -63,7 +66,7 @@ class Git < Output      end    end -  #give a hash of all oid revision for the givin node, and the date of the commit +  #give a hash of all oid revision for the given node, and the date of the commit      def version node, group        begin          repo = @cfg.repo @@ -176,7 +179,7 @@ class Git < Output      if tree_old != tree_new        repo.config['user.name']  = user        repo.config['user.email'] = email -      Rugged::Commit.create(repo, +      @commitref = Rugged::Commit.create(repo,          :tree       => index.write_tree(repo),          :message    => msg,          :parents    => repo.empty? ? [] : [repo.head.target].compact, diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index eea747e..c886a5b 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -39,11 +39,13 @@ module Oxidized          msg = "update #{node.name}"          msg += " from #{node.from}" if node.from          msg += " with message '#{node.msg}'" if node.msg -        if node.output.new.store node.name, job.config, +        output = node.output.new +        if output.store node.name, job.config,                                :msg => msg, :user => node.user, :group => node.group            Log.info "Configuration updated for #{node.group}/#{node.name}"            Oxidized.Hooks.handle :post_store, :node => node, -                                             :job => job +                                             :job => job, +                                             :commitref => output.commitref          end          node.reset        else | 
