summaryrefslogtreecommitdiff
path: root/README.markdown
blob: 9671fc59247c5fe907ae61f4c893072e55b9f9a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
#vcsrepo

[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo)

####Table of Contents

1. [Overview](#overview)
2. [Module Description - What the module does and why it is useful](#module-description)
3. [Setup - The basics of getting started with vcsrepo](#setup)
    * [Beginning with vcsrepo](#beginning-with-vcsrepo)
4. [Usage - Configuration options and additional functionality](#usage)
    * [Bazaar](#bazaar)
    * [CVS](#cvs)
    * [Git](#git)
    * [Mercurial](#mercurial)
    * [Perforce](#perforce)
    * [Subversion](#subversion)  
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
    * [Type: vcsrepo](#type-vcsrepo)
        * [Providers](#providers)
        * [Features](#features)
        * [Parameters](#parameters)
        * [Features and Parameters by Provider](#features-and-parameters-by-provider)
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)

##Overview

The vcsrepo module allows you to use Puppet to easily deploy content from your version control system (VCS).

##Module Description

This module provides a single type with providers for each VCS, which can be used to describe: 

* A working copy checked out from a (remote or local) source, at an
  arbitrary revision
* A blank working copy not associated with a source (when it makes
  sense for the VCS being used)
* A blank central repository (when the distinction makes sense for the VCS
  being used)   

##Setup

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.

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.

###Beginning with vcsrepo	

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). 

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => git,
    }

##Usage

The vcsrepo module works with the following VCSs:

* [Git (git)](#git)*
* [Bazaar (bzr)](#bazaar)
* [CVS (cvs)](#cvs)
* [Mercurial (hg)](#mercurial)
* [Perforce (p4)](#perforce)
* [Subversion (svn)](#subversion)

**Note:** Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.


###Git

#####To create a blank repository

To create a blank repository suitable for use as a central repository,
define `vcsrepo` without `source` or `revision`.

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => git,
    }

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'.

    vcsrepo { "/path/to/repo":
      ensure   => bare,
      provider => git,
    }

#####To clone/pull a repository

To get the current HEAD on the master branch,

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => git,
      source   => "git://example.com/repo.git",
    }

To get a specific revision or branch (can be a commit SHA, tag, or branch name),

 **SHA**

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => git,
      source   => 'git://example.com/repo.git',
      revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
    }

**Tag**

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => git,
      source   => 'git://example.com/repo.git',
      revision => '1.1.2rc1',
    }

**Branch name**

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => git,
      source   => 'git://example.com/repo.git',
      revision => 'development',
    }

To check out a branch as a specific user,

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => git,
      source   => 'git://example.com/repo.git',
      revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
      user     => 'someUser',
    }

To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository),

    vcsrepo { "/path/to/repo":
      ensure   => latest,
      provider => git,
      source   => 'git://example.com/repo.git',
      revision => 'master',
    }

To clone the repository but skip initialiazing submodules,

    vcsrepo { "/path/to/repo":
      ensure     => latest,
      provider   => git,
      source     => 'git://example.com/repo.git',
      submodules => false,
    }

##### Using multiple remotes with a repository
Instead of specifying a single string in the 'source' property, you can specify a hash with multiple name => URL mappings,

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => git,
      source   => {
        "origin"       => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", 
        "other_remote" => "https://github.com/other_user/puppetlabs-vcsrepo.git"
      },
    }

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.

#####Sources that use SSH

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.

For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys.

    user => 'toto'  # will use toto's $HOME/.ssh setup

#####Further Examples

For more examples using Git, see `examples/git/`.

###Bazaar

#####Create a blank repository

To create a blank repository suitable for use as a central repository,
define `vcsrepo` without `source` or `revision`.

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => bzr,
    }

#####Branch from an existing repository

Provide the `source` location to branch from an existing repository.

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => bzr,
      source   => 'lp:myproj',
    }

For a specific revision, use `revision` with a valid revisionspec
(see `bzr help revisionspec` for more information on formatting a revision).

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => bzr,
      source   => 'lp:myproj',
      revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x',
    }

#####Sources that use SSH

When your source uses SSH, for instance 'bzr+ssh://...' or 'sftp://...,'
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.
  
#####Further examples

For more examples using Bazaar, see `examples/bzr/`.

###CVS

#####To create a blank repository

To create a blank repository suitable for use as a central repository,
define `vcsrepo` without `source` or `revision`.

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => cvs,
    }

#####To checkout/update from a repository

To get the current mainline,

    vcsrepo { "/path/to/workspace":
      ensure   => present,
      provider => cvs,
      source   => ":pserver:anonymous@example.com:/sources/myproj",
    }
    
To get a specific module on the current mainline,

    vcsrepo {"/vagrant/lockss-daemon-source":
      ensure   => present,
      provider => cvs,
      source   => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss",
      module   => "lockss-daemon",
    }


You can use the `compression` parameter to set the GZIP compression levels for your repository history.

    vcsrepo { "/path/to/workspace":
      ensure      => present,
      provider    => cvs,
      compression => 3,
      source      => ":pserver:anonymous@example.com:/sources/myproj",
    }

For a specific tag, use `revision`.

    vcsrepo { "/path/to/workspace":
      ensure      => present,
      provider    => cvs,
      compression => 3,
      source      => ":pserver:anonymous@example.com:/sources/myproj",
      revision    => "SOMETAG",
    }

#####Sources that use SSH

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.

#####Further examples

For for more examples using CVS, see `examples/cvs/`.

###Mercurial

#####To create a blank repository

To create a blank repository suitable for use as a central repository,
define `vcsrepo` without `source` or `revision`.

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => hg,
    }

#####To clone/pull & update a repository

To get the default branch tip,

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => hg,
      source   => "http://hg.example.com/myrepo",
    }

For a specific changeset, use `revision`.

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => hg,
      source   => "http://hg.example.com/myrepo",
      revision => '21ea4598c962',
    }

You can also set `revision` to a tag.

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => hg,
      source   => "http://hg.example.com/myrepo",
      revision => '1.1.2',
    }

To check out as a specific user,

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => hg,
      source   => "http://hg.example.com/myrepo",
      user     => 'user',
    }

To specify an SSH identity key,

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => hg,
      source   => "ssh://hg@hg.example.com/myrepo",
      identity => "/home/user/.ssh/id_dsa,
    }

To specify a username and password for HTTP Basic authentication,

    vcsrepo { "/path/to/repo":
      ensure   => latest,
      provider => hg,
      source   => 'http://hg.example.com/myrepo',
      basic_auth_username => 'hgusername',
      basic_auth_password => 'hgpassword',
    }

#####Sources that use SSH 

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.

#####Further Examples

For more examples using Mercurial, see `examples/hg/`.

###Perforce

#####To create an empty Workspace

To create an empty Workspace, define a `vcsrepo` without a `source` or `revision`.  The 
Environment variables P4PORT, P4USER, etc... are used to define the Perforce server
connection settings.

    vcsrepo { "/path/to/repo":
      ensure     => present,
      provider   => p4
    }

If no `P4CLIENT` environment name is provided a workspace generated name is calculated
based on the Digest of path and hostname.  For example:

    puppet-91bc00640c4e5a17787286acbe2c021c

A Perforce configuration file can be used by setting the `P4CONFIG` environment or
defining `p4config`.  If a configuration is defined, then the environment variable for 
`P4CLIENT` is replaced.
 
    vcsrepo { "/path/to/repo":
      ensure     => present,
      provider   => p4,
      p4config   => '.p4config'
    }

#####To create/update and sync a Perforce workspace

To sync a depot path to head, ensure `latest`:

    vcsrepo { "/path/to/repo":
        ensure   => latest,
        provider => p4,
        source   => '//depot/branch/...'
    }

For a specific changelist, ensure `present` and specify a `revision`:

    vcsrepo { "/path/to/repo":
        ensure   => present,
        provider => p4,
        source   => '//depot/branch/...',
        revision => '2341'
    }

You can also set `revision` to a label:

    vcsrepo { "/path/to/repo":
        ensure   => present,
        provider => p4,
        source   => '//depot/branch/...',
        revision => 'my_label'
    }

#####To authenticate against the Perforce server

Either set the environment variables `P4USER` and `P4PASSWD` or use a configuration file.
For secure servers set the `P4PASSWD` with a valid ticket generated using `p4 login -p`.

#####Further Examples

For examples you can run, see `examples/p4/`

###Subversion

#####To create a blank repository

To create a blank repository suitable for use as a central repository,
define `vcsrepo` without `source` or `revision`.

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => svn,
    }

#####To check out from a repository

Provide a `source` pointing to the branch/tag you want to check out from a repository.

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => svn,
      source   => "svn://svnrepo/hello/branches/foo",
    }

You can also provide a specific revision.

    vcsrepo { "/path/to/repo":
      ensure   => present,
      provider => svn,
      source   => "svn://svnrepo/hello/branches/foo",
      revision => '1234',
    }

#####Using a specific Subversion configuration directory 

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'.

    vcsrepo { "/path/to/repo":
        ensure        => present,
        provider      => svn,
        source        => "svn://svnrepo/hello/branches/foo",
        configuration => "/path/to/.subversion",
    }

#####Sources that use SSH 

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.

####Further examples

For more examples using Subversion, see `examples/svn/`.

##Reference

###Type: vcsrepo

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. 

####Providers

**Note**: Not all features are available with all providers.

* `git`   - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.)
* `bar`   - Supports the Bazaar VCS. (Contains features: `reference_tracking`.)
* `cvs`   - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`.)
* `dummy` - 
* `hg`    - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.)
* `p4`    - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.)
* `svn`   - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.)

####Features

**Note**: Not all features are available with all providers.

* `bare_repositories` - The provider differentiates between bare repositories and those with working copies. (Available with `git`.)
* `basic_auth` -  The provider supports HTTP Basic Authentication. (Available with `svn`.)
* `configuration` - The provider supports setting the configuration path.(Available with `svn`.)
* `cvs_rsh` - The provider understands the CVS_RSH environment variable. (Available with `cvs`.)
* `depth` - The provider can do shallow clones. (Available with `git`.)
* `filesystem_types` - The provider supports different filesystem types. (Available with `svn`.)
* `gzip_compression` - The provider supports explicit GZip compression levels. (Available with `cvs`.)
* `modules` - The provider allows specific repository modules to be chosen. (Available with `cvs`.)
* `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.)
* `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`.)
* `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.)
* `user` - The provider can run as a different user. (Available with `git`, `hg` and `cvs`.)
* `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.)
* `submodules` - The provider supports repository submodules which can be optionally initialized. (Available with `git`.)

####Parameters

* `basic_auth_password` - Specifies the HTTP Basic Authentication password. (Requires the `basic_auth` feature.)
* `basic_auth_username` - Specifies the HTTP Basic Authentication username. (Requires the `basic_auth` feature.)
* `compression` - Set the GZIP compression levels for your repository history. (Requires the `gzip_compression` feature.)
* `configuration` - Sets the configuration directory to use. (Requires the `configuration` feature.)
* `cvs_rsh` -  The value to be used for the CVS_RSH environment variable. (Requires the `cvs_rsh` feature.)
* `depth` - The value to be used to do a shallow clone. (Requires the `depth` feature.)
* `ensure` - Determines the state of the repository. Valid values are 'present', 'bare', 'absent', 'latest'.
* `excludes` - Lists any files to be excluded from being tracked by the repository (similiar to .gitignore). Can be an array or string.
* `force` - Forces repository creation. Valid values are 'true' and 'false'. **WARNING** Forcing will destroy any files in the path.
* `fstype` - Sets the filesystem type. (Requires the `filesystem_types` feature.)
* `group` - Determines the group/gid that owns the repository files.
* `identity` - Specifies the SSH identity file. (Requires the `ssh_identity` feature.)
* `module` - Specifies the repository module to manage. (Requires the `modules` feature.)
* `owner` - Specifies the user/uid that owns the repository files.
* `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title.
* `provider` - Specifies the backend to use for this vcsrepo resource. 
* `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.)
* `revision` - Sets the revision of the repository. Values can match /^\S+$/.
* `source` - Specifies the source URI for the repository.
* `user` - Specifies the user to run as for repository operations.
* `p4config` - Specifies the P4CONFIG environment used for Perforce connection configuration.

####Features and Parameters by Provider

#####`git`
**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`, `submodules`

**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`, `submodules`

#####`bzr`
**Features**: `reference_tracking`

**Parameters**: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user`

#####`cvs`
**Features**: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `revision`

**Parameters**: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`, `revision`, `source`, `user`

#####`hg`
**Features**: `reference_tracking`, `ssh_identity`, `user`

**Parameters**: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user`

#####`p4`
**Features**: `reference_tracking`, `filesystem_types`, `p4config`

**Parameters**: `ensure`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `p4config`

#####`svn`
**Features**: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`

**Parameters**: `basic_auth_password`, `basic_auth_username`, `configuration`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user`
        
##Limitations

Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.

This module has been built on and tested against Puppet 2.7 and higher.

The module has been tested on:

RedHat Enterprise Linux 5/6
Debian 6/7
CentOS 5/6
Ubuntu 12.04
Gentoo
Arch Linux
FreeBSD

Testing on other platforms has been light and cannot be guaranteed.

##Development

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.

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.

You can read the complete module contribution guide on the Puppet Labs wiki.