3 [](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo)
7 1. [Overview](#overview)
8 2. [Module Description - What the module does and why it is useful](#module-description)
9 3. [Setup - The basics of getting started with vcsrepo](#setup)
10 * [Beginning with vcsrepo](#beginning-with-vcsrepo)
11 4. [Usage - Configuration options and additional functionality](#usage)
15 * [Mercurial](#mercurial)
16 * [Perforce](#perforce)
17 * [Subversion](#subversion)
18 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
19 * [Type: vcsrepo](#type-vcsrepo)
20 * [Providers](#providers)
21 * [Features](#features)
22 * [Parameters](#parameters)
23 * [Features and Parameters by Provider](#features-and-parameters-by-provider)
24 5. [Limitations - OS compatibility, etc.](#limitations)
25 6. [Development - Guide for contributing to the module](#development)
29 The vcsrepo module allows you to use Puppet to easily deploy content from your version control system (VCS).
33 This module provides a single type with providers for each VCS, which can be used to describe:
35 * A working copy checked out from a (remote or local) source, at an
37 * A blank working copy not associated with a source (when it makes
38 sense for the VCS being used)
39 * A blank central repository (when the distinction makes sense for the VCS
44 Before you begin using vcsrepo, it's worth keeping in mind that this module will not install VCS software for you. If you are going to use this module, you must have already installed your preferred VCS.
46 Also, this module, like Puppet generally, will not create parent directories for you. You will need to have your parent directories in place before you begin.
48 ###Beginning with vcsrepo
50 To get started with the vcsrepo module, you must simply define the type `vcsrepo` with a path to your repository and the [type of VCS](#Usage) you're using in `provider` (in the below example, Git).
52 vcsrepo { "/path/to/repo":
59 The vcsrepo module works with the following VCSs:
62 * [Bazaar (bzr)](#bazaar)
64 * [Mercurial (hg)](#mercurial)
65 * [Perforce (p4)](#perforce)
66 * [Subversion (svn)](#subversion)
68 **Note:** Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.
73 #####To create a blank repository
75 To create a blank repository suitable for use as a central repository,
76 define `vcsrepo` without `source` or `revision`.
78 vcsrepo { "/path/to/repo":
83 If you're defining `vcsrepo` for a central or official repository, you may want to make it a bare repository. You do this by setting `ensure` to 'bare' rather than 'present'.
85 vcsrepo { "/path/to/repo":
90 #####To clone/pull a repository
92 To get the current HEAD on the master branch,
94 vcsrepo { "/path/to/repo":
97 source => "git://example.com/repo.git",
100 To get a specific revision or branch (can be a commit SHA, tag, or branch name),
104 vcsrepo { "/path/to/repo":
107 source => 'git://example.com/repo.git',
108 revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
113 vcsrepo { "/path/to/repo":
116 source => 'git://example.com/repo.git',
117 revision => '1.1.2rc1',
122 vcsrepo { "/path/to/repo":
125 source => 'git://example.com/repo.git',
126 revision => 'development',
129 To check out a branch as a specific user,
131 vcsrepo { "/path/to/repo":
134 source => 'git://example.com/repo.git',
135 revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
139 To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository),
141 vcsrepo { "/path/to/repo":
144 source => 'git://example.com/repo.git',
145 revision => 'master',
148 To clone the repository but skip initialiazing submodules,
150 vcsrepo { "/path/to/repo":
153 source => 'git://example.com/repo.git',
157 #####Sources that use SSH
159 When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
161 For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys.
163 user => 'toto' # will use toto's $HOME/.ssh setup
165 #####Further Examples
167 For more examples using Git, see `examples/git/`.
171 #####Create a blank repository
173 To create a blank repository suitable for use as a central repository,
174 define `vcsrepo` without `source` or `revision`.
176 vcsrepo { "/path/to/repo":
181 #####Branch from an existing repository
183 Provide the `source` location to branch from an existing repository.
185 vcsrepo { "/path/to/repo":
188 source => 'lp:myproj',
191 For a specific revision, use `revision` with a valid revisionspec
192 (see `bzr help revisionspec` for more information on formatting a revision).
194 vcsrepo { "/path/to/repo":
197 source => 'lp:myproj',
198 revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x',
201 #####Sources that use SSH
203 When your source uses SSH, for instance 'bzr+ssh://...' or 'sftp://...,'
204 you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
206 #####Further examples
208 For more examples using Bazaar, see `examples/bzr/`.
212 #####To create a blank repository
214 To create a blank repository suitable for use as a central repository,
215 define `vcsrepo` without `source` or `revision`.
217 vcsrepo { "/path/to/repo":
222 #####To checkout/update from a repository
224 To get the current mainline,
226 vcsrepo { "/path/to/workspace":
229 source => ":pserver:anonymous@example.com:/sources/myproj",
232 To get a specific module on the current mainline,
234 vcsrepo {"/vagrant/lockss-daemon-source":
237 source => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss",
238 module => "lockss-daemon",
242 You can use the `compression` parameter to set the GZIP compression levels for your repository history.
244 vcsrepo { "/path/to/workspace":
248 source => ":pserver:anonymous@example.com:/sources/myproj",
251 For a specific tag, use `revision`.
253 vcsrepo { "/path/to/workspace":
257 source => ":pserver:anonymous@example.com:/sources/myproj",
258 revision => "SOMETAG",
261 #####Sources that use SSH
263 When your source uses SSH, you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
265 #####Further examples
267 For for more examples using CVS, see `examples/cvs/`.
271 #####To create a blank repository
273 To create a blank repository suitable for use as a central repository,
274 define `vcsrepo` without `source` or `revision`.
276 vcsrepo { "/path/to/repo":
281 #####To clone/pull & update a repository
283 To get the default branch tip,
285 vcsrepo { "/path/to/repo":
288 source => "http://hg.example.com/myrepo",
291 For a specific changeset, use `revision`.
293 vcsrepo { "/path/to/repo":
296 source => "http://hg.example.com/myrepo",
297 revision => '21ea4598c962',
300 You can also set `revision` to a tag.
302 vcsrepo { "/path/to/repo":
305 source => "http://hg.example.com/myrepo",
309 To check out as a specific user,
311 vcsrepo { "/path/to/repo":
314 source => "http://hg.example.com/myrepo",
318 To specify an SSH identity key,
320 vcsrepo { "/path/to/repo":
323 source => "ssh://hg@hg.example.com/myrepo",
324 identity => "/home/user/.ssh/id_dsa,
327 To specify a username and password for HTTP Basic authentication,
329 vcsrepo { "/path/to/repo":
332 source => 'http://hg.example.com/myrepo',
333 basic_auth_username => 'hgusername',
334 basic_auth_password => 'hgpassword',
337 #####Sources that use SSH
339 When your source uses SSH, such as 'ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
341 #####Further Examples
343 For more examples using Mercurial, see `examples/hg/`.
347 #####To create an empty Workspace
349 To create an empty Workspace, define a `vcsrepo` without a `source` or `revision`. The
350 Environment variables P4PORT, P4USER, etc... are used to define the Perforce server
353 vcsrepo { "/path/to/repo":
358 If no `P4CLIENT` environment name is provided a workspace generated name is calculated
359 based on the Digest of path and hostname. For example:
361 puppet-91bc00640c4e5a17787286acbe2c021c
363 A Perforce configuration file can be used by setting the `P4CONFIG` environment or
364 defining `p4config`. If a configuration is defined, then the environment variable for
365 `P4CLIENT` is replaced.
367 vcsrepo { "/path/to/repo":
370 p4config => '.p4config'
373 #####To create/update and sync a Perforce workspace
375 To sync a depot path to head, ensure `latest`:
377 vcsrepo { "/path/to/repo":
380 source => '//depot/branch/...'
383 For a specific changelist, ensure `present` and specify a `revision`:
385 vcsrepo { "/path/to/repo":
388 source => '//depot/branch/...',
392 You can also set `revision` to a label:
394 vcsrepo { "/path/to/repo":
397 source => '//depot/branch/...',
398 revision => 'my_label'
401 #####To authenticate against the Perforce server
403 Either set the environment variables `P4USER` and `P4PASSWD` or use a configuration file.
404 For secure servers set the `P4PASSWD` with a valid ticket generated using `p4 login -p`.
406 #####Further Examples
408 For examples you can run, see `examples/p4/`
412 #####To create a blank repository
414 To create a blank repository suitable for use as a central repository,
415 define `vcsrepo` without `source` or `revision`.
417 vcsrepo { "/path/to/repo":
422 #####To check out from a repository
424 Provide a `source` pointing to the branch/tag you want to check out from a repository.
426 vcsrepo { "/path/to/repo":
429 source => "svn://svnrepo/hello/branches/foo",
432 You can also provide a specific revision.
434 vcsrepo { "/path/to/repo":
437 source => "svn://svnrepo/hello/branches/foo",
441 #####Using a specific Subversion configuration directory
443 To use a specific configuration directory, provide a `configuration` parameter which should be a directory path on the local system where your svn configuration files are. Typically, it is '/path/to/.subversion'.
445 vcsrepo { "/path/to/repo":
448 source => "svn://svnrepo/hello/branches/foo",
449 configuration => "/path/to/.subversion",
452 #####Sources that use SSH
454 When your source uses SSH, such as 'svn+ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
458 For more examples using Subversion, see `examples/svn/`.
464 The vcsrepo module is slightly unusual in that it is simply a type and providers. Each provider abstracts a different VCS, and a series of features are available to each provider based on its specific needs.
468 **Note**: Not all features are available with all providers.
470 * `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.)
471 * `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.)
472 * `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`.)
474 * `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.)
475 * `p4` - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.)
476 * `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.)
480 **Note**: Not all features are available with all providers.
482 * `bare_repositories` - The provider differentiates between bare repositories and those with working copies. (Available with `git`.)
483 * `basic_auth` - The provider supports HTTP Basic Authentication. (Available with `svn`.)
484 * `configuration` - The provider supports setting the configuration path.(Available with `svn`.)
485 * `cvs_rsh` - The provider understands the CVS_RSH environment variable. (Available with `cvs`.)
486 * `depth` - The provider can do shallow clones. (Available with `git`.)
487 * `filesystem_types` - The provider supports different filesystem types. (Available with `svn`.)
488 * `gzip_compression` - The provider supports explicit GZip compression levels. (Available with `cvs`.)
489 * `modules` - The provider allows specific repository modules to be chosen. (Available with `cvs`.)
490 * `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.)
491 * `reference_tracking` - The provider supports tracking revision references that can change over time (e.g. some VCS tags and branch names). (Available with `bar`, `cvs`, `git`, `hg`, `svn`.)
492 * `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.)
493 * `user` - The provider can run as a different user. (Available with `git`, `hg` and `cvs`.)
494 * `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.)
495 * `submodules` - The provider supports repository submodules which can be optionally initialized. (Available with `git`.)
499 * `basic_auth_password` - Specifies the HTTP Basic Authentication password. (Requires the `basic_auth` feature.)
500 * `basic_auth_username` - Specifies the HTTP Basic Authentication username. (Requires the `basic_auth` feature.)
501 * `compression` - Set the GZIP compression levels for your repository history. (Requires the `gzip_compression` feature.)
502 * `configuration` - Sets the configuration directory to use. (Requires the `configuration` feature.)
503 * `cvs_rsh` - The value to be used for the CVS_RSH environment variable. (Requires the `cvs_rsh` feature.)
504 * `depth` - The value to be used to do a shallow clone. (Requires the `depth` feature.)
505 * `ensure` - Determines the state of the repository. Valid values are 'present', 'bare', 'absent', 'latest'.
506 * `excludes` - Lists any files to be excluded from the repository. Can be an array or string.
507 * `force` - Forces repository creation. Valid values are 'true' and 'false'. **WARNING** Forcing will destroy any files in the path.
508 * `fstype` - Sets the filesystem type. (Requires the `filesystem_types` feature.)
509 * `group` - Determines the group/gid that owns the repository files.
510 * `identity` - Specifies the SSH identity file. (Requires the `ssh_identity` feature.)
511 * `module` - Specifies the repository module to manage. (Requires the `modules` feature.)
512 * `owner` - Specifies the user/uid that owns the repository files.
513 * `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title.
514 * `provider` - Specifies the backend to use for this vcsrepo resource.
515 * `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.)
516 * `revision` - Sets the revision of the repository. Values can match /^\S+$/.
517 * `source` - Specifies the source URI for the repository.
518 * `user` - Specifies the user to run as for repository operations.
519 * `p4config` - Specifies the P4CONFIG environment used for Perforce connection configuration.
521 ####Features and Parameters by Provider
524 **Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`, `submodules`
526 **Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`, `submodules`
529 **Features**: `reference_tracking`
531 **Parameters**: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user`
534 **Features**: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `revision`
536 **Parameters**: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`, `revision`, `source`, `user`
539 **Features**: `reference_tracking`, `ssh_identity`, `user`
541 **Parameters**: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user`
544 **Features**: `reference_tracking`, `filesystem_types`, `p4config`
546 **Parameters**: `ensure`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `p4config`
549 **Features**: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`
551 **Parameters**: `basic_auth_password`, `basic_auth_username`, `configuration`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user`
555 Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.
557 This module has been built on and tested against Puppet 2.7 and higher.
559 The module has been tested on:
561 RedHat Enterprise Linux 5/6
569 Testing on other platforms has been light and cannot be guaranteed.
573 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.
575 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.
577 You can read the complete module contribution guide on the Puppet Labs wiki.