Puppet Class: reposync
- Defined in:
- modules/reposync/manifests/init.pp
Summary
class to configure the primary reposync serverOverview
SPDX-License-Identifier: Apache-2.0
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});
}
}
}
|