9.6.1. Example git::repository Usage
The following is an example of node1.example.org that runs a git server with a git repository for program1, being developed by department, under the resposibility of manager.
node 'host1.example.org' {
git::repository { "program1":
owner => "manager",
group => "department",
public => false,
shared => true,
recipients => [ "department@example.org", "manager@example.org" ],
description => "SCM for program1"
}
}
This creates a bare git repository in /srv/git/program1/, and a symlink /git/program1 => /srv/git/program1/. The script sets the ownership of /srv/git/program1/ to manager:department, and the mode to 2770 so that the users that are a member of the department group can write to the directory (which is necessary to push), but no other user can check out the repository. Note that for group write access, shared should be set to true as shown in the example.
If one or more commits are pushed to the repository, the email addresses specified in the recipients parameter to the git::repository type will get a notification via email, including a diff.
9.6.1.1. Using the symlink_prefix attribute
The symlink_prefix attribute can be used to allow multiple equally named git repositories in different locations on the system to be symlinked in /git/ without conflicting with the other git repository with the same name. In particular, the $name variable remains the same so that within the git::repository type definition it can be used as-is.
The symlink_prefix attribute is used as follows:
node 'node1.example.org' {
# GIT repositories for puppet modules
git::repository { [
"git",
"puppet",
"webserver"
]:
symlink_prefix => "puppet-module",
public => true,
shared => true,
group => "contributors",
localtree => "/data/scm/git/git.puppetmanaged.org/",
recipients => [ "contributors@example.org" ]
}
}
Note how it defines more repositories, and puts them in
/data/scm/git/git.puppetmanaged.org/, with group ownership for
contributors. Normally, a symlink such as
/git/webserver => /data/scm/git/git.puppetmanaged.org/webserver/ would be created, but if we did that, then no other git repository can be named
webserver anymore. Given that we specify a
symlink_prefix of
puppet-module, the symbolic link created will be
/git/puppet-module-webserver => /data/scm/git/git.puppetmanaged.org/webserver/. See the
What's the use of symlink_prefix? FAQ for more details.
9.6.1.2. Using the prefix attribute
The prefix attribute is used to prepend a string to the name of the git repository. Note that this attribute in fact replaces $name as far as repository locations and symbolic links is concerned, while the $name variable remains available within the git::repository type definition.
This attribute comes to life when the $name variable needs to be used inside the git::repository type definition, but the repository's location and symbolic links to that location need to be prepended.
The prefix attribute is prepended to the name of the repository. Below is an example use of the prefix parameter.
node 'node1.example.org' {
# Git repositories for puppet modules
git::repository { [
"git",
"puppet",
"webserver"
]:
symlink_prefix => "puppet",
prefix => "module",
public => true,
shared => true,
group => "contributors",
localtree => "/data/scm/git/git.puppetmanaged.org/",
recipients => [ "contributors@example.org" ]
}
}
Now, the git repository webserver will be created as /data/scm/git/git.puppetmanaged.org/module-webserver/, as well as a symbolic link /git/puppet-module-webserver => /data/scm/git/git.puppetmanaged.org/module-webserver/.