puppet-prod/site/profiles/manifests/puppet/r10k.pp
Ben Vincent 58d31c5c9a chore: migrate puppet-r10k
- moved puppet-r10k the unkin organisation
- ensure branch is set to follow origin/master
2024-11-17 19:26:27 +11:00

62 lines
1.5 KiB
Puppet

# Class: profiles::puppet::r10k
#
# This class manages a Git repository at /etc/puppetlabs/r10k. It includes a
# systemd service and timer to keep the repository updated every minute.
# The Git package is installed if not present, and the repository at the given
# location will always reflect the state of the remote Git repository.
class profiles::puppet::r10k (
String $r10k_repo,
){
vcsrepo { '/etc/puppetlabs/r10k':
ensure => latest,
provider => git,
source => $r10k_repo,
require => Package['git'],
}
file { '/opt/puppetlabs/bin/puppet-r10k':
ensure => file,
owner => 'root',
group => 'root',
mode => '0755',
content => "#!/bin/bash\n(
cd /etc/puppetlabs/r10k
git branch --set-upstream-to=origin/master master
git reset --hard master
git clean -fd
git pull\n)",
require => Package['git'],
}
$_timer = @(EOT)
[Unit]
Description=puppet-r10k downloader timer
[Timer]
OnCalendar=*:0/5
RandomizedDelaySec=1s
[Install]
WantedBy=timers.target
EOT
$_service = @(EOT)
[Unit]
Description=puppet-r10k downloader service
[Service]
Type=oneshot
ExecStart=/opt/puppetlabs/bin/puppet-r10k
User=root
Group=root
PermissionsStartOnly=false
PrivateTmp=no
EOT
systemd::timer { 'puppet-r10k.timer':
timer_content => $_timer,
service_content => $_service,
active => true,
enable => true,
require => File['/opt/puppetlabs/bin/puppet-r10k'],
}
}