From 9a827169e2c566ce744c2c160640e119d5f85e6d Mon Sep 17 00:00:00 2001 From: Rudolfs Osins Date: Mon, 19 Jan 2015 15:33:43 +0100 Subject: [PATCH] Update plugins only if there is a newer version A 'git pull' always generates a change event in Puppet even if there are no changes in the upstream repository. This is bad for monitoring, for example the puppet dashboard always shows all the plugins installed by rbenv-puppet as changes for every run on every node. This change makes sure that 'git pull' is only run when there is a new version of the plugin upstream. --- manifests/plugin.pp | 1 + spec/defines/rbenv__plugin_spec.rb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index d4e86a4..31ddc2e 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -46,6 +46,7 @@ timeout => $timeout, cwd => $destination, require => Exec["rbenv::plugin::checkout ${user} ${plugin_name}"], + onlyif => 'git remote update; if [ "$(git rev-parse @{0})" = "$(git rev-parse @{u})" ]; then return 0; else return 1; fi ]', } } diff --git a/spec/defines/rbenv__plugin_spec.rb b/spec/defines/rbenv__plugin_spec.rb index 2dbe067..20181af 100644 --- a/spec/defines/rbenv__plugin_spec.rb +++ b/spec/defines/rbenv__plugin_spec.rb @@ -26,7 +26,10 @@ :user => user, :cwd => target_path, :require => /rbenv::plugin::checkout #{user} #{plugin_name}/, - :path => ['/bin','/usr/bin','/usr/sbin'] + :path => ['/bin','/usr/bin','/usr/sbin'], + :onlyif => 'git remote update; ' \ + 'if [ "$(git rev-parse @{0})" = "$(git rev-parse @{u})" ]; ' \ + 'then return 0; else return 1; fi ]' ) end