Puppet Class: reposync

Defined in:
modules/reposync/manifests/init.pp

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: 'present')

    ensureable parameter

  • manage_base (Boolean) (defaults to: true)

    set to false if the base directory is managed else where

  • owner (String[1]) (defaults to: 'root')

    the user to use as owner of the repos

  • group (String[1]) (defaults to: 'root')

    the group to use as owner of the repos

  • target_only (Boolean) (defaults to: false)

    only configure repos dont install spicerack config

  • repos (Array[String[1]]) (defaults to: [])

    list of repositories

  • remotes (Array[Stdlib::Host]) (defaults to: [])

    list of remotes



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
# File 'modules/reposync/manifests/init.pp', line 10

class reposync (
    Wmflib::Ensure      $ensure      = 'present',
    Boolean             $manage_base = true,
    String[1]           $owner       = 'root',
    String[1]           $group       = 'root',
    Boolean             $target_only = false,
    Array[String[1]]    $repos       = [],
    Array[Stdlib::Host] $remotes     = [],
) {

    # config file used by spicerack
    $config_file = '/etc/spicerack/reposync/config.yaml'
    $base_dir = '/srv/reposync'
    $config = {'base_dir' => $base_dir, 'repos' => $repos, 'remotes' => $remotes}

    if $manage_base {
        wmflib::dir::mkdir_p([$base_dir])
    }
    unless $target_only {
        wmflib::dir::mkdir_p([$config_file.dirname])
        file {$config_file:
            ensure  => stdlib::ensure($ensure, 'file'),
            owner   => 'root',
            content => $config.to_yaml,
        }
    }
    $repos.each |$repo| {
        $repo_path = "${base_dir}/${repo}"
        file { $repo_path:
            ensure  => stdlib::ensure($ensure, 'directory'),
            owner   => $owner,
            group   => $group,
            recurse => true,
        }
        exec { "git_init_${repo}":
            command => "/usr/bin/git -C ${repo_path} init --bare",
            user    => $owner,
            creates => "${repo_path}/HEAD",
            require => File[$repo_path],
        }
        file {
            default:
                owner   => $owner,
                group   => $group,
                require => Exec["git_init_${repo}"];
            "${repo_path}/hooks":
                ensure  => stdlib::ensure($ensure, 'directory');
            "${repo_path}/hooks/post-update":
                ensure  => stdlib::ensure($ensure, 'file'),
                mode    => '0550',
                content => "#!/bin/sh\nexec /usr/bin/git update-server-info\n";
            "${repo_path}/config":
                ensure  => stdlib::ensure($ensure, 'file'),
                mode    => '0440',
                content => epp('reposync/config.epp', {'repo_path' => $repo_path, 'remotes' => $remotes});
        }
    }
}