system-config/modules/openstack_project/manifests/pypi_mirror.pp
Michael Krotscheck 3aabacedc8 Separate concerns in pypi_mirror.pp
This patch separates the creation of the bandersnatch pypi mirror
from the creation of the apache vhost, and parameterizes the data
directory in which bandersnatch places its packages.

This is done so that we may reuse the pypi_mirror.pp module when
building our new unified mirrors, which host pypi assets in a
different directory and under a different hostname and URI.

This patch should not trigger any changes on the existing mirrors.

Change-Id: I55286df53d8dd84ea2377035b830cd92d378ad39
2015-12-21 04:32:42 -08:00

66 lines
1.5 KiB
Puppet

# == Class: openstack_project::pypi_mirror
#
class openstack_project::pypi_mirror (
$data_directory = '/srv/static/mirror',
$cron_frequency = '*/5',
) {
file { "${data_directory}":
ensure => directory,
owner => 'root',
group => 'root',
}
file { "${data_directory}/web":
ensure => directory,
owner => 'root',
group => 'root',
require => File["${data_directory}"],
}
package { 'bandersnatch':
ensure => 'latest',
provider => 'pip',
}
file { '/etc/bandersnatch.conf':
ensure => present,
content => template('openstack_project/bandersnatch.conf.erb'),
}
file { '/var/log/bandersnatch':
ensure => directory,
}
file { '/var/run/bandersnatch':
ensure => directory,
}
cron { 'bandersnatch':
minute => $cron_frequency,
command => 'flock -n /var/run/bandersnatch/mirror.lock timeout -k 2m 30m run-bandersnatch >>/var/log/bandersnatch/mirror.log 2>&1',
environment => 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',
}
include logrotate
logrotate::file { 'bandersnatch':
log => '/var/log/bandersnatch/mirror.log',
options => [
'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
}
file { '/usr/local/bin/run-bandersnatch':
ensure => present,
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/openstack_project/run_bandersnatch.py',
}
}