Product SiteDocumentation Site

9.6. Example Usage

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