diff --git a/lib/oxidized/hook/exec.rb b/lib/oxidized/hook/exec.rb index b0da53a5d..2cbe4b77f 100644 --- a/lib/oxidized/hook/exec.rb +++ b/lib/oxidized/hook/exec.rb @@ -71,6 +71,7 @@ def make_env(ctx) "OX_REPO_NAME" => ctx.node.repo.to_s, "OX_ERR_TYPE" => ctx.node.err_type.to_s, "OX_ERR_REASON" => ctx.node.err_reason.to_s + "OX_NODE_VARS" => JSON.dump(ctx.node.vars) ) end if ctx.job diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb index e770148ee..0d61ed92b 100644 --- a/lib/oxidized/output/file.rb +++ b/lib/oxidized/output/file.rb @@ -21,9 +21,9 @@ def setup def store(node, outputs, opt = {}) file = ::File.expand_path @cfg.directory - file = ::File.join ::File.dirname(file), opt[:group] if opt[:group] + file = ::File.join ::File.dirname(file), node.group if node.group FileUtils.mkdir_p file - file = ::File.join file, node + file = ::File.join file, node.name ::File.write(file, outputs.to_cfg) @commitref = file end diff --git a/lib/oxidized/output/git.rb b/lib/oxidized/output/git.rb index e3f2d1586..3677492fb 100644 --- a/lib/oxidized/output/git.rb +++ b/lib/oxidized/output/git.rb @@ -35,10 +35,10 @@ def setup end end - def store(file, outputs, opt = {}) + def store(node.name, outputs, opt = {}) @msg = opt[:msg] - @user = opt[:user] || @cfg.user - @email = opt[:email] || @cfg.email + @user = node.user || @cfg.user + @email = node.email || @cfg.email @opt = opt @commitref = nil repo = @cfg.repo @@ -48,17 +48,17 @@ def store(file, outputs, opt = {}) type_repo = File.join(File.dirname(repo), type + '.git') outputs.type(type).each do |output| (type_cfg << output; next) unless output.name # rubocop:disable Style/Semicolon - type_file = file + '--' + output.name + type_file = node.name + '--' + output.name if @cfg.type_as_directory? type_file = type + '/' + type_file type_repo = repo end update type_repo, type_file, output end - update type_repo, file, type_cfg + update type_repo, node.name, type_cfg end - update repo, file, outputs.to_cfg + update repo, node.name, outputs.to_cfg end # Returns the configuration of group/node_name diff --git a/lib/oxidized/output/gitcrypt.rb b/lib/oxidized/output/gitcrypt.rb index b23ec44a3..fd796a978 100644 --- a/lib/oxidized/output/gitcrypt.rb +++ b/lib/oxidized/output/gitcrypt.rb @@ -63,10 +63,10 @@ def unlock(repo) end end - def store(file, outputs, opt = {}) + def store(node, outputs, opt = {}) @msg = opt[:msg] - @user = opt[:user] || @cfg.user - @email = opt[:email] || @cfg.email + @user = node.user || @cfg.user + @email = node.email || @cfg.email @opt = opt @commitref = nil repo = @cfg.repo @@ -76,17 +76,17 @@ def store(file, outputs, opt = {}) type_repo = File.join(File.dirname(repo), type + '.git') outputs.type(type).each do |output| (type_cfg << output; next) unless output.name # rubocop:disable Style/Semicolon - type_file = file + '--' + output.name + type_file = node.name + '--' + output.name if @cfg.type_as_directory? type_file = type + '/' + type_file type_repo = repo end update type_repo, type_file, output end - update type_repo, file, type_cfg + update type_repo, node.name, type_cfg end - update repo, file, outputs.to_cfg + update repo, node.name, outputs.to_cfg end def fetch(node, group) diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index 34fec779b..44bbb7f7a 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -69,8 +69,7 @@ def process_success(node, job) msg += " from #{node.from}" if node.from msg += " with message '#{node.msg}'" if node.msg output = node.output.new - if output.store node.name, job.config, - msg: msg, email: node.email, user: node.user, group: node.group + if output.store node, job.config, msg: msg node.modified Oxidized.logger.info "Configuration updated for #{node.group}/#{node.name}" Oxidized.hooks.handle :post_store, node: node,