Ask Your Question

Can vcsrepo Update Based on Newer Revision or Local Git Not in Sync?

asked 2018-08-27 09:43:12 -0500

nmajin gravatar image

Based on my testing, it seems like vcsrepo is not capable of updating if the local cloned repo get's out of sync with the remote. Is there any way we can request a parameter for this scenario? The following parameters don't work in this situation:

ensure => latest Will only update if there is a new revision in the repo

force => true Will constantly delete the local path and pull the laetest. This is not ideal if the repo does not change often since the manifest will be deleting and cloning the repo on x amount of servers all the time.

This sounds like something that should have been addressed a while ago, so what am I missing in terms of why this capability is not there?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-27 11:27:25 -0500

binford2k gravatar image

It sounds like what you're saying is that you do something in the local git repository and then you want Puppet to instruct git to throw away the things you have done. First question is why you're developing in a Puppet managed git repository? I'm having a hard time understanding what need that serves.

To answer your question though, it's unlikely that the module would ever do that, simply because it by definition would be intentionally discarding data. Can you imagine the uproar as soon as someone lost important data because they didn't know this would occur? That's also why git makes it hard to do this as well.

To get what you're asking for, you'd need to write an exec something like this.

exec { "git reset --hard && git clean -dfx":
    path     => '/bin:/usr/bin',
    unless   => '[ -z "$(git status --porcelain)" ]',
    provider => 'shell',

See the docs at:

edit flag offensive delete link more


Thanks for the response. Your exec is pretty much what I would have to do here. vcsrepo would work great if the repos cloned on the hosts could not be messed or tweaked with, which unfortunately is not the case here. I guess puppet assumes files should be managed in modules; not entirely in a repo.

nmajin gravatar imagenmajin ( 2018-08-28 22:47:40 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2018-08-27 09:43:12 -0500

Seen: 12 times

Last updated: Aug 27