5 1. [Overview](#overview)
6 2. [Module Description - What the module does and why it is useful](#module-description)
7 3. [Setup - The basics of getting started with vcsrepo](#setup)
8 * [Setup requirements](#setup-requirements)
9 * [Beginning with vcsrepo](#beginning-with-vcsrepo)
10 4. [Usage - Configuration options and additional functionality](#usage)
14 * [Mercurial](#mercurial)
15 * [Perforce](#perforce)
16 * [Subversion](#subversion)
17 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
18 * [Type: vcsrepo](#type-vcsrepo)
19 * [Providers](#providers)
20 * [Features](#features)
21 * [Parameters](#parameters)
22 5. [Limitations - OS compatibility, etc.](#limitations)
23 6. [Development - Guide for contributing to the module](#development)
27 The vcsrepo module lets you use Puppet to easily deploy content from your version control system (VCS).
31 The vcsrepo module provides a single type with providers to support the following version control systems:
36 * [Mercurial](#mercurial)
37 * [Perforce](#perforce)
38 * [Subversion](#subversion)
40 **Note:** `git` is the only vcs provider officially [supported by Puppet Labs](https://forge.puppetlabs.com/supported).
46 The `vcsrepo` module does not install any VCS software for you. You must install a VCS before you can use this module.
48 Like Puppet in general, the `vcsrepo` module does not automatically create parent directories for the files it manages. Make sure to set up any needed directory structures before you get started.
50 ###Beginning with vcsrepo
52 To create and manage a blank repository, define the type `vcsrepo` with a path to your repository and supply the `provider` parameter based on the [VCS you're using](#usage).
55 vcsrepo { '/path/to/repo':
63 **Note:** `git` is the only vcsrepo provider officially [supported by Puppet Labs](https://forge.puppetlabs.com/supported).
67 ####Create a blank repository
69 To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`:
72 vcsrepo { '/path/to/repo':
78 If you're managing a central or official repository, you might want to make it a bare repository. To do this, set `ensure` to 'bare':
81 vcsrepo { '/path/to/repo':
87 ####Clone/pull a repository
90 vcsrepo { '/path/to/repo':
93 source => 'git://example.com/repo.git',
97 By default, `vcsrepo` will use the HEAD of the source repository's master branch. To use another branch or a specific commit, set `revision` to either a branch name or a commit SHA or tag.
102 vcsrepo { '/path/to/repo':
105 source => 'git://example.com/repo.git',
106 revision => 'development',
113 vcsrepo { '/path/to/repo':
116 source => 'git://example.com/repo.git',
117 revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
124 vcsrepo { '/path/to/repo':
127 source => 'git://example.com/repo.git',
128 revision => '1.1.2rc1',
132 To check out a branch as a specific user, supply the `user` parameter:
135 vcsrepo { '/path/to/repo':
138 source => 'git://example.com/repo.git',
139 revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
144 To keep the repository at the latest revision, set `ensure` to 'latest'.
146 **WARNING:** this overwrites any local changes to the repository:
149 vcsrepo { '/path/to/repo':
152 source => 'git://example.com/repo.git',
153 revision => 'master',
157 To clone the repository but skip initializing submodules, set `submodules` to 'false':
160 vcsrepo { '/path/to/repo':
163 source => 'git://example.com/repo.git',
168 ####Use multiple remotes with a repository
169 In place of a single string, you can set `source` to a hash of one or more name => URL pairs:
172 vcsrepo { '/path/to/repo':
177 'origin' => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git',
178 'other_remote' => 'https://github.com/other_user/puppetlabs-vcsrepo.git'
183 **Note:** if you set `source` to a hash, one of the names you specify must match the value of the `remote` parameter. That remote serves as the upstream of your managed repository.
187 To connect to your source repository via SSH (e.g., 'username@server:…'), we recommend managing your SSH keys with Puppet and using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure they are present before the `vcsrepo` resource is applied.
189 To use SSH keys associated with a user, specify the username in the `user` parameter:
192 vcsrepo { '/path/to/repo':
195 source => 'git://username@example.com/repo.git',
196 user => 'toto', #uses toto's $HOME/.ssh setup
197 require => File['/home/toto/.ssh/id_rsa'],
203 ####Create a blank repository
205 To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`:
208 vcsrepo { '/path/to/repo':
214 ####Branch from an existing repository
217 vcsrepo { '/path/to/repo':
220 source => '/some/path',
224 To branch from a specific revision, set `revision` to a valid [Bazaar revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec):
227 vcsrepo { '/path/to/repo':
230 source => '/some/path',
231 revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x',
237 To connect to your source repository via SSH (e.g., `'bzr+ssh://...'` or `'sftp://...,'`), we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied:
240 vcsrepo { '/path/to/repo':
243 source => 'bzr+ssh://bzr.example.com/some/path',
244 user => 'toto', #uses toto's $HOME/.ssh setup
245 require => File['/home/toto/.ssh/id_rsa'],
251 ####Create a blank repository
253 To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`:
256 vcsrepo { '/path/to/repo':
262 ####Checkout/update from a repository
265 vcsrepo { '/path/to/workspace':
268 source => ':pserver:anonymous@example.com:/sources/myproj',
272 To get a specific module on the current mainline, supply the `module` parameter:
275 vcsrepo {'/vagrant/lockss-daemon-source':
278 source => ':pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss',
279 module => 'lockss-daemon',
283 To set the GZIP compression levels for your repository history, use the `compression` parameter:
286 vcsrepo { '/path/to/workspace':
290 source => ':pserver:anonymous@example.com:/sources/myproj',
294 To get a specific revision, set `revision` to the revision number.
297 vcsrepo { '/path/to/workspace':
301 source => ':pserver:anonymous@example.com:/sources/myproj',
306 You can also set `revision` to a tag:
309 vcsrepo { '/path/to/workspace':
313 source => ':pserver:anonymous@example.com:/sources/myproj',
314 revision => 'SOMETAG',
320 To connect to your source repository via SSH, we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied:
323 vcsrepo { '/path/to/repo':
326 source => ':pserver:anonymous@example.com:/sources/myproj',
327 user => 'toto', #uses toto's $HOME/.ssh setup
328 require => File['/home/toto/.ssh/id_rsa'],
334 ####Create a blank repository
336 To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`:
339 vcsrepo { '/path/to/repo':
345 ####Clone/pull & update a repository
347 To get the default branch tip:
350 vcsrepo { '/path/to/repo':
353 source => 'http://hg.example.com/myrepo',
357 For a specific changeset, use `revision`:
360 vcsrepo { '/path/to/repo':
363 source => 'http://hg.example.com/myrepo',
364 revision => '21ea4598c962',
368 You can also set `revision` to a tag:
371 vcsrepo { '/path/to/repo':
374 source => 'http://hg.example.com/myrepo',
379 To check out as a specific user:
382 vcsrepo { '/path/to/repo':
385 source => 'http://hg.example.com/myrepo',
390 To specify an SSH identity key:
393 vcsrepo { '/path/to/repo':
396 source => 'ssh://hg@hg.example.com/myrepo',
397 identity => '/home/user/.ssh/id_dsa1,
401 To specify a username and password for HTTP Basic authentication:
404 vcsrepo { '/path/to/repo':
407 source => 'http://hg.example.com/myrepo',
408 basic_auth_username => 'hgusername',
409 basic_auth_password => 'hgpassword',
415 To connect to your source repository via SSH (e.g., `'ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied:
418 vcsrepo { '/path/to/repo':
421 source => 'ssh://hg.example.com//path/to/myrepo',
422 user => 'toto', #uses toto's $HOME/.ssh setup
423 require => File['/home/toto/.ssh/id_rsa'],
429 ####Create an empty workspace
431 To set up the connection to your Perforce service, set `p4config` to the location of a valid Perforce [config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles) stored on the node:
434 vcsrepo { '/path/to/repo':
437 p4config => '/root/.p4config'
441 **Note:** If you don't include the `P4CLIENT` setting in your config file, the provider generates a workspace name based on the digest of `path` and the node's hostname (e.g., `puppet-91bc00640c4e5a17787286acbe2c021c`):
443 ####Create/update and sync a Perforce workspace
445 To sync a depot path to head, set `ensure` to 'latest':
448 vcsrepo { '/path/to/repo':
451 source => '//depot/branch/...'
455 To sync to a specific changelist, specify its revision number with the `revision` parameter:
458 vcsrepo { '/path/to/repo':
461 source => '//depot/branch/...',
466 You can also set `revision` to a label:
469 vcsrepo { '/path/to/repo':
472 source => '//depot/branch/...',
473 revision => 'my_label'
479 ####Create a blank repository
482 vcsrepo { '/path/to/repo':
488 ####Check out from an existing repository
490 Provide a `source` pointing to the branch or tag you want to check out:
493 vcsrepo { '/path/to/repo':
496 source => 'svn://svnrepo/hello/branches/foo',
500 You can also designate a specific revision:
503 vcsrepo { '/path/to/repo':
506 source => 'svn://svnrepo/hello/branches/foo',
511 ####Use a specific Subversion configuration directory
513 Use the `configuration` parameter to designate the directory that contains your Subversion configuration files (typically, '/path/to/.subversion'):
516 vcsrepo { '/path/to/repo':
519 source => 'svn://svnrepo/hello/branches/foo',
520 configuration => '/path/to/.subversion',
526 To connect to your source repository via SSH (e.g., `'svn+ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied:
529 vcsrepo { '/path/to/repo':
532 source => 'svn+ssh://svnrepo/hello/branches/foo',
533 user => 'toto', #uses toto's $HOME/.ssh setup
534 require => File['/home/toto/.ssh/id_rsa'],
542 The vcsrepo module adds only one type with several providers. Each provider abstracts a different VCS, and each provider includes a set of features according to its needs.
546 **Note:** Not all features are available with all providers.
548 #####`git` - Supports the Git VCS.
550 Features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `submodules`, `user`
552 Parameters: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`
554 #####`bzr` - Supports the Bazaar VCS.
556 Features: `reference_tracking`
558 Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source`
560 #####`cvs` - Supports the CVS VCS.
562 Features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`
564 Parameters: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`
566 #####`hg` - Supports the Mercurial VCS.
568 Features: `reference_tracking`, `ssh_identity`, `user`
570 Parameters: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user`
572 #####`p4` - Supports the Perforce VCS.
574 Features: `p4config`, `reference_tracking`
576 Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `p4config`, `path`, `provider`, `revision`, `source`
578 #####`svn` - Supports the Subversion VCS.
580 Features: `basic_auth`, `configuration`, `conflict`, `depth`, `filesystem_types`, `reference_tracking`
582 Parameters: `basic_auth_password`, `basic_auth_username`, `configuration`, `conflict`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `trust_server_cert`
586 **Note:** Not all features are available with all providers.
588 * `bare_repositories` - Differentiates between bare repositories and those with working copies. (Available with `git`.)
589 * `basic_auth` - Supports HTTP Basic authentication. (Available with `svn`.)
590 * `conflict` - Lets you decide how to resolve any conflicts between the source repository and your working copy. (Available with `svn`.)
591 * `configuration` - Lets you specify the location of your configuration files. (Available with `svn`.)
592 * `cvs_rsh` - Understands the `CVS_RSH` environment variable. (Available with `cvs`.)
593 * `depth` - Supports shallow clones in `git` or sets scope limit in `svn`. (Available with `git` and `svn`.)
594 * `filesystem_types` - Supports multiple types of filesystem. (Available with `svn`.)
595 * `gzip_compression` - Supports explicit GZip compression levels. (Available with `cvs`.)
596 * `modules` - Lets you choose a specific repository module. (Available with `cvs`.)
597 * `multiple_remotes` - Tracks multiple remote repositories. (Available with `git`.)
598 * `reference_tracking` - Lets you track revision references that can change over time (e.g., some VCS tags and branch names). (Available with all providers)
599 * `ssh_identity` - Lets you specify an SSH identity file. (Available with `git` and `hg`.)
600 * `user` - Can run as a different user. (Available with `git`, `hg` and `cvs`.)
601 * `p4config` - Supports setting the `P4CONFIG` environment. (Available with `p4`.)
602 * `submodules` - Supports repository submodules which can be optionally initialized. (Available with `git`.)
606 All parameters are optional, except where specified otherwise.
608 ##### `basic_auth_password`
610 Specifies the password for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none.
612 ##### `basic_auth_username`
614 Specifies the username for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none.
618 Sets the GZIP compression level for the repository history. (Requires the `gzip_compression` feature.) Valid options: an integer between 0 and 6. Default: none.
620 ##### `configuration`
622 Sets the configuration directory to use. (Requires the `configuration` feature.) Valid options: a string containing an absolute path. Default: none.
626 Tells Subversion how to resolve any conflicts between the source repository and your working copy. (Requires the `conflict` feature.) Valid options: 'base', 'mine-full', 'theirs-full', and 'working'. Default: none.
630 Provides a value for the `CVS_RSH` environment variable. (Requires the `cvs_rsh` feature.) Valid options: a string. Default: none.
634 In `git` sets the number of commits to include when creating a shallow clone. (Requires the `depth` feature.) Valid options: an integer. Default: none.
636 In `svn` instructs Subversion to limit the scope of an operation to a particular tree depth. (Requires the `depth` feature.) Valid options: 'empty', 'files', 'immediates', 'infinity'. Default: none.
640 Specifies whether the repository should exist. Valid options: 'present', 'bare', 'absent', and 'latest'. Default: 'present'.
644 Lists any files the repository shouldn't track (similar to .gitignore). Valid options: a string (separate multiple values with the newline character). Default: none.
648 Specifies whether to delete any existing files in the repository path if creating a new repository. **Use with care.** Valid options: 'true' and 'false'. Default: 'false'.
652 Sets the filesystem type. (Requires the `filesystem_types` feature.) Valid options: 'fsfs' or 'bdb'. Default: none.
656 Specifies a group to own the repository files. Valid options: a string containing a group name or GID. Default: none.
660 Specifies an identity file to use for SSH authentication. (Requires the `ssh_identity` feature.) Valid options: a string containing an absolute path. Default: none.
664 Specifies the repository module to manage. (Requires the `modules` feature.) Valid options: a string containing the name of a CVS module. Default: none.
668 Specifies a user to own the repository files. Valid options: a string containing a username or UID. Default: none.
672 Specifies a config file that contains settings for connecting to the Perforce service. (Requires the `p4config` feature.) Valid options: a string containing the absolute path to a valid [Perforce config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles). Default: none.
676 Specifies a location for the managed repository. Valid options: a string containing an absolute path. Default: the title of your declared resource.
680 *Required.* Specifies the backend to use for this vcsrepo resource. Valid options: 'bzr', 'cvs', 'git', 'hg', 'p4', and 'svn'.
684 Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) Valid options: a string containing one of the remote names specified in `source`. Default: 'origin'.
688 Sets the revision of the repository. Valid options vary by provider:
690 * `git` - a string containing a Git branch name, or a commit SHA or tag
691 * `bzr` - a string containing a Bazaar [revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec)
692 * `cvs` - a string containing a CVS [tag or revision number](http://www.thathost.com/wincvs-howto/cvsdoc/cvs_4.html)
693 * `hg` - a string containing a Mercurial [changeset ID](http://mercurial.selenic.com/wiki/ChangeSetID) or [tag](http://mercurial.selenic.com/wiki/Tag)
694 * `p4` - a string containing a Perforce [change number, label name, client name, or date spec](http://www.perforce.com/perforce/r12.1/manuals/cmdref/o.fspecs.html)
695 * `svn` - a string containing a Subversion [revision number](http://svnbook.red-bean.com/en/1.7/svn.basic.in-action.html#svn.basic.in-action.revs), [revision keyword, or revision date](http://svnbook.red-bean.com/en/1.7/svn.tour.revs.specifiers.html)
701 Specifies a source repository to serve as the upstream for your managed repository. Default: none. Valid options vary by provider:
703 * `git` - a string containing a [Git repository URL](https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#_git_urls_a_id_urls_a) or a hash of name => URL mappings. See also [`remote`](#remote).
704 * `bzr` - a string containing a Bazaar branch location
705 * `cvs` - a string containing a CVS root
706 * `hg` - a string containing the local path or URL of a Mercurial repository
707 * `p4` - a string containing a Perforce depot path
708 * `svn` - a string containing a Subversion repository URL
714 Specifies whether to initialize and update each submodule in the repository. (Requires the `submodules` feature.) Valid options: 'true' and 'false'. Default: 'true'.
716 ##### `trust_server_cert`
718 Instructs Subversion to accept SSL server certificates issued by unknown certificate authorities. Valid options: 'true' and 'false'. Default: 'false'.
722 Specifies the user to run as for repository operations. (Requires the `user` feature.) Valid options: a string containing a username or UID. Default: none.
726 Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.
728 This module has been tested with Puppet 2.7 and higher.
730 The module has been tested on:
735 * Red Hat Enterprise Linux 5/6/7
736 * Scientific Linux 5/6/7
738 * Ubuntu 10.04/12.04/14.04
740 Testing on other platforms has been light and cannot be guaranteed.
744 Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.
746 We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
748 You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing)