ddc7889df1
* modules/openstack_project/manifests/pypi_mirror.pp: Bandersnatch occasionally seems to livelock in a select poll loop at teardown. https://bitbucket.org/pypa/bandersnatch/issue/52 As such this blocks subsequent runs of our wrapper script, filling the log with useless tracebacks every 5 minutes while leaving the mirror perpetually stale until someone comes along and notices. Work around this unfortunate situation by setting a half hour timeout on the process, and add a file lock to the invocation so that it will not try to run more instances of the wrapper script until the current one terminates. Change-Id: I055b623801af3063d22b081eb9c9ef3634e5e5b5
89 lines
2.0 KiB
Puppet
89 lines
2.0 KiB
Puppet
# == Class: openstack_project::pypi_mirror
|
|
#
|
|
class openstack_project::pypi_mirror (
|
|
$vhost_name,
|
|
) {
|
|
|
|
include apache
|
|
|
|
if ! defined(File['/srv/static']) {
|
|
file { '/srv/static':
|
|
ensure => directory,
|
|
}
|
|
}
|
|
|
|
file { '/srv/static/mirror':
|
|
ensure => directory,
|
|
owner => 'root',
|
|
group => 'root',
|
|
}
|
|
|
|
file { '/srv/static/mirror/web':
|
|
ensure => directory,
|
|
owner => 'root',
|
|
group => 'root',
|
|
require => File['/srv/static/mirror'],
|
|
}
|
|
|
|
apache::vhost { $vhost_name:
|
|
port => 80,
|
|
priority => '50',
|
|
docroot => '/srv/static/mirror/web',
|
|
require => File['/srv/static/mirror/web'],
|
|
}
|
|
|
|
file { '/srv/static/mirror/web/robots.txt':
|
|
ensure => present,
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0444',
|
|
source => 'puppet:///modules/openstack_project/disallow_robots.txt',
|
|
require => File['/srv/static/mirror/web'],
|
|
}
|
|
|
|
package { 'bandersnatch':
|
|
ensure => 'present',
|
|
provider => 'pip',
|
|
}
|
|
|
|
file { '/etc/bandersnatch.conf':
|
|
ensure => present,
|
|
source => 'puppet:///modules/openstack_project/bandersnatch.conf',
|
|
}
|
|
|
|
file { '/var/log/bandersnatch':
|
|
ensure => directory,
|
|
}
|
|
|
|
file { '/var/run/bandersnatch':
|
|
ensure => directory,
|
|
}
|
|
|
|
cron { 'bandersnatch':
|
|
minute => '*/5',
|
|
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',
|
|
}
|
|
}
|