Split pypi_mirror into its own class
We want to run more than one of these, and not all on static.o.o, so as a first step, split the relevant code out into a class. Change-Id: I6b3dd294bef3c89ad6353ecdae815ebd6825b0e1
This commit is contained in:
parent
4ed7c43aa4
commit
f2e542afa7
84
modules/openstack_project/manifests/pypi_mirror.pp
Normal file
84
modules/openstack_project/manifests/pypi_mirror.pp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
# == 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,
|
||||||
|
}
|
||||||
|
|
||||||
|
cron { 'bandersnatch':
|
||||||
|
minute => '*/5',
|
||||||
|
command => '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',
|
||||||
|
}
|
||||||
|
}
|
@ -33,8 +33,10 @@ class openstack_project::static (
|
|||||||
ensure => present,
|
ensure => present,
|
||||||
}
|
}
|
||||||
|
|
||||||
file { '/srv/static':
|
if ! defined(File['/srv/static']) {
|
||||||
ensure => directory,
|
file { '/srv/static':
|
||||||
|
ensure => directory,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
@ -200,22 +202,11 @@ class openstack_project::static (
|
|||||||
require => File['/srv/static/docs-draft'],
|
require => File['/srv/static/docs-draft'],
|
||||||
}
|
}
|
||||||
|
|
||||||
###########################################################
|
class { 'openstack_project::pypi_mirror':
|
||||||
# Pypi Mirror
|
vhost_name => 'pypi.openstack.org',
|
||||||
|
|
||||||
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'],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Legacy pypi mirror
|
||||||
file { '/srv/static/mirror/web/openstack':
|
file { '/srv/static/mirror/web/openstack':
|
||||||
ensure => directory,
|
ensure => directory,
|
||||||
owner => 'jenkins',
|
owner => 'jenkins',
|
||||||
@ -223,63 +214,6 @@ class openstack_project::static (
|
|||||||
require => [User['jenkins'], File['/srv/static/mirror']],
|
require => [User['jenkins'], File['/srv/static/mirror']],
|
||||||
}
|
}
|
||||||
|
|
||||||
apache::vhost { 'pypi.openstack.org':
|
|
||||||
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,
|
|
||||||
}
|
|
||||||
|
|
||||||
cron { 'bandersnatch':
|
|
||||||
minute => '*/5',
|
|
||||||
command => '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',
|
|
||||||
}
|
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
# Specs
|
# Specs
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user