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 #####Sources that use SSH
150 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.
152 For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys.
154 user => 'toto' # will use toto's $HOME/.ssh setup
156 #####Further Examples
158 For more examples using Git, see `examples/git/`.
162 #####Create a blank repository
164 To create a blank repository suitable for use as a central repository,
165 define `vcsrepo` without `source` or `revision`.
167 vcsrepo { "/path/to/repo":
172 #####Branch from an existing repository
174 Provide the `source` location to branch from an existing repository.
176 vcsrepo { "/path/to/repo":
179 source => 'lp:myproj',
182 For a specific revision, use `revision` with a valid revisionspec
183 (see `bzr help revisionspec` for more information on formatting a revision).
185 vcsrepo { "/path/to/repo":
188 source => 'lp:myproj',
189 revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x',
192 #####Sources that use SSH
194 When your source uses SSH, for instance 'bzr+ssh://...' or 'sftp://...,'
195 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.
197 #####Further examples
199 For more examples using Bazaar, see `examples/bzr/`.
203 #####To create a blank repository
205 To create a blank repository suitable for use as a central repository,
206 define `vcsrepo` without `source` or `revision`.
208 vcsrepo { "/path/to/repo":
213 #####To checkout/update from a repository
215 To get the current mainline,
217 vcsrepo { "/path/to/workspace":
220 source => ":pserver:anonymous@example.com:/sources/myproj",
223 To get a specific module on the current mainline,
225 vcsrepo {"/vagrant/lockss-daemon-source":
228 source => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss",
229 module => "lockss-daemon",
233 You can use the `compression` parameter to set the GZIP compression levels for your repository history.
235 vcsrepo { "/path/to/workspace":
239 source => ":pserver:anonymous@example.com:/sources/myproj",
242 For a specific tag, use `revision`.
244 vcsrepo { "/path/to/workspace":
248 source => ":pserver:anonymous@example.com:/sources/myproj",
249 revision => "SOMETAG",
252 #####Sources that use SSH
254 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.
256 #####Further examples
258 For for more examples using CVS, see `examples/cvs/`.
262 #####To create a blank repository
264 To create a blank repository suitable for use as a central repository,
265 define `vcsrepo` without `source` or `revision`.
267 vcsrepo { "/path/to/repo":
272 #####To clone/pull & update a repository
274 To get the default branch tip,
276 vcsrepo { "/path/to/repo":
279 source => "http://hg.example.com/myrepo",
282 For a specific changeset, use `revision`.
284 vcsrepo { "/path/to/repo":
287 source => "http://hg.example.com/myrepo",
288 revision => '21ea4598c962',
291 You can also set `revision` to a tag.
293 vcsrepo { "/path/to/repo":
296 source => "http://hg.example.com/myrepo",
300 To check out as a specific user,
302 vcsrepo { "/path/to/repo":
305 source => "http://hg.example.com/myrepo",
309 To specify an SSH identity key,
311 vcsrepo { "/path/to/repo":
314 source => "ssh://hg@hg.example.com/myrepo",
315 identity => "/home/user/.ssh/id_dsa,
318 To specify a username and password for HTTP Basic authentication,
320 vcsrepo { "/path/to/repo":
323 source => 'http://hg.example.com/myrepo',
324 basic_auth_username => 'hgusername',
325 basic_auth_password => 'hgpassword',
328 #####Sources that use SSH
330 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.
332 #####Further Examples
334 For more examples using Mercurial, see `examples/hg/`.
338 #####To create an empty Workspace
340 To create an empty Workspace, define a `vcsrepo` without a `source` or `revision`. The
341 Environment variables P4PORT, P4USER, etc... are used to define the Perforce server
344 vcsrepo { "/path/to/repo":
349 If no `P4CLIENT` environment name is provided a workspace generated name is calculated
350 based on the Digest of path and hostname. For example:
352 puppet-91bc00640c4e5a17787286acbe2c021c
354 A Perforce configuration file can be used by setting the `P4CONFIG` environment or
355 defining `p4config`. If a configuration is defined, then the environment variable for
356 `P4CLIENT` is replaced.
358 vcsrepo { "/path/to/repo":
361 p4config => '.p4config'
364 #####To create/update and sync a Perforce workspace
366 To sync a depot path to head, ensure `latest`:
368 vcsrepo { "/path/to/repo":
371 source => '//depot/branch/...'
374 For a specific changelist, ensure `present` and specify a `revision`:
376 vcsrepo { "/path/to/repo":
379 source => '//depot/branch/...',
383 You can also set `revision` to a label:
385 vcsrepo { "/path/to/repo":
388 source => '//depot/branch/...',
389 revision => 'my_label'
392 #####To authenticate against the Perforce server
394 Either set the environment variables `P4USER` and `P4PASSWD` or use a configuration file.
395 For secure servers set the `P4PASSWD` with a valid ticket generated using `p4 login -p`.
397 #####Further Examples
399 For examples you can run, see `examples/p4/`
403 #####To create a blank repository
405 To create a blank repository suitable for use as a central repository,
406 define `vcsrepo` without `source` or `revision`.
408 vcsrepo { "/path/to/repo":
413 #####To check out from a repository
415 Provide a `source` pointing to the branch/tag you want to check out from a repository.
417 vcsrepo { "/path/to/repo":
420 source => "svn://svnrepo/hello/branches/foo",
423 You can also provide a specific revision.
425 vcsrepo { "/path/to/repo":
428 source => "svn://svnrepo/hello/branches/foo",
432 #####Using a specific Subversion configuration directory
434 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'.
436 vcsrepo { "/path/to/repo":
439 source => "svn://svnrepo/hello/branches/foo",
440 configuration => "/path/to/.subversion",
443 #####Sources that use SSH
445 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.
449 For more examples using Subversion, see `examples/svn/`.
455 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.
459 **Note**: Not all features are available with all providers.
461 * `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.)
462 * `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.)
463 * `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`.)
465 * `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.)
466 * `p4` - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.)
467 * `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.)
471 **Note**: Not all features are available with all providers.
473 * `bare_repositories` - The provider differentiates between bare repositories and those with working copies. (Available with `git`.)
474 * `basic_auth` - The provider supports HTTP Basic Authentication. (Available with `svn`.)
475 * `configuration` - The provider supports setting the configuration path.(Available with `svn`.)
476 * `cvs_rsh` - The provider understands the CVS_RSH environment variable. (Available with `cvs`.)
477 * `depth` - The provider can do shallow clones. (Available with `git`.)
478 * `filesystem_types` - The provider supports different filesystem types. (Available with `svn`.)
479 * `gzip_compression` - The provider supports explicit GZip compression levels. (Available with `cvs`.)
480 * `modules` - The provider allows specific repository modules to be chosen. (Available with `cvs`.)
481 * `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.)
482 * `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`.)
483 * `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.)
484 * `user` - The provider can run as a different user. (Available with `git`, `hg` and `cvs`.)
485 * `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.)
489 * `basic_auth_password` - Specifies the HTTP Basic Authentication password. (Requires the `basic_auth` feature.)
490 * `basic_auth_username` - Specifies the HTTP Basic Authentication username. (Requires the `basic_auth` feature.)
491 * `compression` - Set the GZIP compression levels for your repository history. (Requires the `gzip_compression` feature.)
492 * `configuration` - Sets the configuration directory to use. (Requires the `configuration` feature.)
493 * `cvs_rsh` - The value to be used for the CVS_RSH environment variable. (Requires the `cvs_rsh` feature.)
494 * `depth` - The value to be used to do a shallow clone. (Requires the `depth` feature.)
495 * `ensure` - Determines the state of the repository. Valid values are 'present', 'bare', 'absent', 'latest'.
496 * `excludes` - Lists any files to be excluded from the repository. Can be an array or string.
497 * `force` - Forces repository creation. Valid values are 'true' and 'false'. **WARNING** Forcing will destroy any files in the path.
498 * `fstype` - Sets the filesystem type. (Requires the `filesystem_types` feature.)
499 * `group` - Determines the group/gid that owns the repository files.
500 * `identity` - Specifies the SSH identity file. (Requires the `ssh_identity` feature.)
501 * `module` - Specifies the repository module to manage. (Requires the `modules` feature.)
502 * `owner` - Specifies the user/uid that owns the repository files.
503 * `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title.
504 * `provider` - Specifies the backend to use for this vcsrepo resource.
505 * `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.)
506 * `revision` - Sets the revision of the repository. Values can match /^\S+$/.
507 * `source` - Specifies the source URI for the repository.
508 * `user` - Specifies the user to run as for repository operations.
509 * `p4config` - Specifies the P4CONFIG environment used for Perforce connection configuration.
511 ####Features and Parameters by Provider
514 **Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`
516 **Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`
519 **Features**: `reference_tracking`
521 **Parameters**: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user`
524 **Features**: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `revision`
526 **Parameters**: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`, `revision`, `source`, `user`
529 **Features**: `reference_tracking`, `ssh_identity`, `user`
531 **Parameters**: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user`
534 **Features**: `reference_tracking`, `filesystem_types`, `p4config`
536 **Parameters**: `ensure`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `p4config`
539 **Features**: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`
541 **Parameters**: `basic_auth_password`, `basic_auth_username`, `configuration`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user`
545 Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.
547 This module has been built on and tested against Puppet 2.7 and higher.
549 The module has been tested on:
551 RedHat Enterprise Linux 5/6
559 Testing on other platforms has been light and cannot be guaranteed.
563 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.
565 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.
567 You can read the complete module contribution guide on the Puppet Labs wiki.