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 ##### Using multiple remotes with a repository
158 Instead of specifying a single string in the 'source' property, you can specify a hash with multiple name => URL mappings,
160 vcsrepo { "/path/to/repo":
164 "origin" => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git",
165 "other_remote" => "https://github.com/other_user/puppetlabs-vcsrepo.git"
169 It is important to note that you must specify a mapping for the remote that is specified in the 'remote' property - this is set to 'origin' by default.
171 #####Sources that use SSH
173 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.
175 For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys.
177 user => 'toto' # will use toto's $HOME/.ssh setup
179 #####Further Examples
181 For more examples using Git, see `examples/git/`.
185 #####Create a blank repository
187 To create a blank repository suitable for use as a central repository,
188 define `vcsrepo` without `source` or `revision`.
190 vcsrepo { "/path/to/repo":
195 #####Branch from an existing repository
197 Provide the `source` location to branch from an existing repository.
199 vcsrepo { "/path/to/repo":
202 source => 'lp:myproj',
205 For a specific revision, use `revision` with a valid revisionspec
206 (see `bzr help revisionspec` for more information on formatting a revision).
208 vcsrepo { "/path/to/repo":
211 source => 'lp:myproj',
212 revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x',
215 #####Sources that use SSH
217 When your source uses SSH, for instance 'bzr+ssh://...' or 'sftp://...,'
218 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.
220 #####Further examples
222 For more examples using Bazaar, see `examples/bzr/`.
226 #####To create a blank repository
228 To create a blank repository suitable for use as a central repository,
229 define `vcsrepo` without `source` or `revision`.
231 vcsrepo { "/path/to/repo":
236 #####To checkout/update from a repository
238 To get the current mainline,
240 vcsrepo { "/path/to/workspace":
243 source => ":pserver:anonymous@example.com:/sources/myproj",
246 To get a specific module on the current mainline,
248 vcsrepo {"/vagrant/lockss-daemon-source":
251 source => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss",
252 module => "lockss-daemon",
256 You can use the `compression` parameter to set the GZIP compression levels for your repository history.
258 vcsrepo { "/path/to/workspace":
262 source => ":pserver:anonymous@example.com:/sources/myproj",
265 For a specific tag, use `revision`.
267 vcsrepo { "/path/to/workspace":
271 source => ":pserver:anonymous@example.com:/sources/myproj",
272 revision => "SOMETAG",
275 #####Sources that use SSH
277 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.
279 #####Further examples
281 For for more examples using CVS, see `examples/cvs/`.
285 #####To create a blank repository
287 To create a blank repository suitable for use as a central repository,
288 define `vcsrepo` without `source` or `revision`.
290 vcsrepo { "/path/to/repo":
295 #####To clone/pull & update a repository
297 To get the default branch tip,
299 vcsrepo { "/path/to/repo":
302 source => "http://hg.example.com/myrepo",
305 For a specific changeset, use `revision`.
307 vcsrepo { "/path/to/repo":
310 source => "http://hg.example.com/myrepo",
311 revision => '21ea4598c962',
314 You can also set `revision` to a tag.
316 vcsrepo { "/path/to/repo":
319 source => "http://hg.example.com/myrepo",
323 To check out as a specific user,
325 vcsrepo { "/path/to/repo":
328 source => "http://hg.example.com/myrepo",
332 To specify an SSH identity key,
334 vcsrepo { "/path/to/repo":
337 source => "ssh://hg@hg.example.com/myrepo",
338 identity => "/home/user/.ssh/id_dsa,
341 To specify a username and password for HTTP Basic authentication,
343 vcsrepo { "/path/to/repo":
346 source => 'http://hg.example.com/myrepo',
347 basic_auth_username => 'hgusername',
348 basic_auth_password => 'hgpassword',
351 #####Sources that use SSH
353 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.
355 #####Further Examples
357 For more examples using Mercurial, see `examples/hg/`.
361 #####To create an empty Workspace
363 To create an empty Workspace, define a `vcsrepo` without a `source` or `revision`. The
364 Environment variables P4PORT, P4USER, etc... are used to define the Perforce server
367 vcsrepo { "/path/to/repo":
372 If no `P4CLIENT` environment name is provided a workspace generated name is calculated
373 based on the Digest of path and hostname. For example:
375 puppet-91bc00640c4e5a17787286acbe2c021c
377 A Perforce configuration file can be used by setting the `P4CONFIG` environment or
378 defining `p4config`. If a configuration is defined, then the environment variable for
379 `P4CLIENT` is replaced.
381 vcsrepo { "/path/to/repo":
384 p4config => '.p4config'
387 #####To create/update and sync a Perforce workspace
389 To sync a depot path to head, ensure `latest`:
391 vcsrepo { "/path/to/repo":
394 source => '//depot/branch/...'
397 For a specific changelist, ensure `present` and specify a `revision`:
399 vcsrepo { "/path/to/repo":
402 source => '//depot/branch/...',
406 You can also set `revision` to a label:
408 vcsrepo { "/path/to/repo":
411 source => '//depot/branch/...',
412 revision => 'my_label'
415 #####To authenticate against the Perforce server
417 Either set the environment variables `P4USER` and `P4PASSWD` or use a configuration file.
418 For secure servers set the `P4PASSWD` with a valid ticket generated using `p4 login -p`.
420 #####Further Examples
422 For examples you can run, see `examples/p4/`
426 #####To create a blank repository
428 To create a blank repository suitable for use as a central repository,
429 define `vcsrepo` without `source` or `revision`.
431 vcsrepo { "/path/to/repo":
436 #####To check out from a repository
438 Provide a `source` pointing to the branch/tag you want to check out from a repository.
440 vcsrepo { "/path/to/repo":
443 source => "svn://svnrepo/hello/branches/foo",
446 You can also provide a specific revision.
448 vcsrepo { "/path/to/repo":
451 source => "svn://svnrepo/hello/branches/foo",
455 #####Using a specific Subversion configuration directory
457 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'.
459 vcsrepo { "/path/to/repo":
462 source => "svn://svnrepo/hello/branches/foo",
463 configuration => "/path/to/.subversion",
466 #####Sources that use SSH
468 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.
472 For more examples using Subversion, see `examples/svn/`.
478 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.
482 **Note**: Not all features are available with all providers.
484 * `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.)
485 * `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.)
486 * `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`.)
488 * `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.)
489 * `p4` - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.)
490 * `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.)
494 **Note**: Not all features are available with all providers.
496 * `bare_repositories` - The provider differentiates between bare repositories and those with working copies. (Available with `git`.)
497 * `basic_auth` - The provider supports HTTP Basic Authentication. (Available with `svn`.)
498 * `configuration` - The provider supports setting the configuration path.(Available with `svn`.)
499 * `cvs_rsh` - The provider understands the CVS_RSH environment variable. (Available with `cvs`.)
500 * `depth` - The provider can do shallow clones. (Available with `git`.)
501 * `filesystem_types` - The provider supports different filesystem types. (Available with `svn`.)
502 * `gzip_compression` - The provider supports explicit GZip compression levels. (Available with `cvs`.)
503 * `modules` - The provider allows specific repository modules to be chosen. (Available with `cvs`.)
504 * `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.)
505 * `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`.)
506 * `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.)
507 * `user` - The provider can run as a different user. (Available with `git`, `hg` and `cvs`.)
508 * `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.)
509 * `submodules` - The provider supports repository submodules which can be optionally initialized. (Available with `git`.)
513 * `basic_auth_password` - Specifies the HTTP Basic Authentication password. (Requires the `basic_auth` feature.)
514 * `basic_auth_username` - Specifies the HTTP Basic Authentication username. (Requires the `basic_auth` feature.)
515 * `compression` - Set the GZIP compression levels for your repository history. (Requires the `gzip_compression` feature.)
516 * `configuration` - Sets the configuration directory to use. (Requires the `configuration` feature.)
517 * `cvs_rsh` - The value to be used for the CVS_RSH environment variable. (Requires the `cvs_rsh` feature.)
518 * `depth` - The value to be used to do a shallow clone. (Requires the `depth` feature.)
519 * `ensure` - Determines the state of the repository. Valid values are 'present', 'bare', 'absent', 'latest'.
520 * `excludes` - Lists any files to be excluded from the repository. Can be an array or string.
521 * `force` - Forces repository creation. Valid values are 'true' and 'false'. **WARNING** Forcing will destroy any files in the path.
522 * `fstype` - Sets the filesystem type. (Requires the `filesystem_types` feature.)
523 * `group` - Determines the group/gid that owns the repository files.
524 * `identity` - Specifies the SSH identity file. (Requires the `ssh_identity` feature.)
525 * `module` - Specifies the repository module to manage. (Requires the `modules` feature.)
526 * `owner` - Specifies the user/uid that owns the repository files.
527 * `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title.
528 * `provider` - Specifies the backend to use for this vcsrepo resource.
529 * `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.)
530 * `revision` - Sets the revision of the repository. Values can match /^\S+$/.
531 * `source` - Specifies the source URI for the repository.
532 * `user` - Specifies the user to run as for repository operations.
533 * `p4config` - Specifies the P4CONFIG environment used for Perforce connection configuration.
535 ####Features and Parameters by Provider
538 **Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`, `submodules`
540 **Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`, `submodules`
543 **Features**: `reference_tracking`
545 **Parameters**: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user`
548 **Features**: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `revision`
550 **Parameters**: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`, `revision`, `source`, `user`
553 **Features**: `reference_tracking`, `ssh_identity`, `user`
555 **Parameters**: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user`
558 **Features**: `reference_tracking`, `filesystem_types`, `p4config`
560 **Parameters**: `ensure`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `p4config`
563 **Features**: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`
565 **Parameters**: `basic_auth_password`, `basic_auth_username`, `configuration`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user`
569 Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.
571 This module has been built on and tested against Puppet 2.7 and higher.
573 The module has been tested on:
575 RedHat Enterprise Linux 5/6
583 Testing on other platforms has been light and cannot be guaranteed.
587 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.
589 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.
591 You can read the complete module contribution guide on the Puppet Labs wiki.