Skip to content

Commit

Permalink
Update plugins only if there is a newer version
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Rudolfs Osins committed Jan 19, 2015
1 parent 4e801f1 commit 9a82716
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]',
}

}
5 changes: 4 additions & 1 deletion spec/defines/rbenv__plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9a82716

Please sign in to comment.