Search code examples
windowsgitpuppetgit-clonerspec-puppet

write puppet config to clone github repo


I've written a Puppet module to install Git on Windows. The Puppet Master is Linux.

Is it possible to write a Puppet manifest to clone a GitHub repo using just puppet resources (i.e. without a script or exec)?

This is a private repo, so the solution needs to include secure credentials.


Solution

  • It is indeed possible on Windows! You can use the puppetlabs-vcsrepo module

    Example of it in action Screenshot using a Windows 2012R2 machine in Virtualbox, command-line on the left, GUI on the right.

    Code I used in the example:

    vcsrepo { 'C:\foo':
      ensure   => present,
      provider => git,
      source   => 'https://github.com/puppetlabs/puppetlabs-vcsrepo',
    }
    

    To keep the repository at the latest revision, set ensure to 'latest'. However, this overwrites any local changes to the repository.

    vcsrepo { 'C:\foo':
      ensure   => present,
      provider => git,
      source   => 'https://github.com/puppetlabs/puppetlabs-vcsrepo',
    }
    

    To control what ref, tag, or branch the git repo is on, use the ref parameter:

    vcsrepo { 'C:\foo':
      ensure   => present,
      provider => git,
      source   => 'git://example.com/repo.git',
      revision => 'development',
    }
    
    vcsrepo { 'C:\foo':
      ensure   => present,
      provider => git,
      source   => 'git://example.com/repo.git',
      revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
    }
    
    vcsrepo { 'C:\foo':
      ensure   => present,
      provider => git,
      source   => 'git://example.com/repo.git',
      revision => '1.1.2rc1',
    }