Puppet vcsrepo git checkout branch

gitpuppetvcs

I am using puppet to clone a repo on an agent node. My site.pp contains

node foobar{
   vcsrepo{"home/user1/gitrepo1":
     provider=>git, 
     source=>"https://github.com/foobar/foo.git",
     revision => "remotes/origin/bar",
   }   
}

On the agent when I do git branch after the catalog has been applied, it shows

*(no branch)
master

When I do git branch -a it shows

master
remotes/origin/HEAD -> origin/master  
remotes/origin/bar

I want to be able to checkout the remote "bar" branch. Only specifying the revision=>bar gives the following error. The documentation is not too clear on this either.

err: /Stage[main]//Node[foobar]/Vcsrepo[/home/user1/gitrepo1]: Could not evaluate: Execution of '/usr/bin/git rev-parse bar' returned 128: fatal: ambiguous argument 'bar': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
bar

EDIT: There was a typo in what I had initially posted. I had in fact specified revision=>bar in my site.pp

Thank you.

Best Answer

The branch can be specified with 'revision' (can be a commit SHA, tag or branch name):

vcsrepo { "/path/to/repo":
    ensure => present,
    provider => git,
    source => 'git://example.com/repo.git',
    revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31'
}

vcsrepo { "/path/to/repo":
    ensure => present,
    provider => git,
    source => 'git://example.com/repo.git',
    revision => '1.1.2rc1'
}

vcsrepo { "/path/to/repo":
    ensure => present,
    provider => git,
    source => 'git://example.com/repo.git',
    revision => 'development'
}

https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/master/README.GIT.markdown

Related Topic