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
This commit is contained in:
parent
a1eb4f504e
commit
3aabacedc8
@ -10,7 +10,35 @@ class openstack_project::pypi (
|
||||
sysadmins => $sysadmins,
|
||||
}
|
||||
|
||||
$mirror_root = '/srv/static'
|
||||
$pypi_root = "${mirror_root}/mirror"
|
||||
|
||||
if ! defined(File[$mirror_root]) {
|
||||
file { $mirror_root:
|
||||
ensure => directory,
|
||||
}
|
||||
}
|
||||
|
||||
class { 'openstack_project::pypi_mirror':
|
||||
vhost_name => $vhost_name,
|
||||
data_directory => "${pypi_root}",
|
||||
require => File[$mirror_root]
|
||||
}
|
||||
|
||||
include ::httpd
|
||||
|
||||
::httpd::vhost { $vhost_name:
|
||||
port => 80,
|
||||
priority => '50',
|
||||
docroot => "${pypi_root}/web",
|
||||
require => Class['Openstack_project::Pypi_mirror'],
|
||||
}
|
||||
|
||||
file { "${pypi_root}/web/robots.txt":
|
||||
ensure => present,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0444',
|
||||
source => 'puppet:///modules/openstack_project/disallow_robots.txt',
|
||||
require => Class['Openstack_project::Pypi_mirror'],
|
||||
}
|
||||
}
|
||||
|
@ -1,45 +1,21 @@
|
||||
# == Class: openstack_project::pypi_mirror
|
||||
#
|
||||
class openstack_project::pypi_mirror (
|
||||
$vhost_name,
|
||||
$data_directory = '/srv/static/mirror',
|
||||
$cron_frequency = '*/5',
|
||||
) {
|
||||
|
||||
include ::httpd
|
||||
|
||||
if ! defined(File['/srv/static']) {
|
||||
file { '/srv/static':
|
||||
ensure => directory,
|
||||
}
|
||||
}
|
||||
|
||||
file { '/srv/static/mirror':
|
||||
file { "${data_directory}":
|
||||
ensure => directory,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
}
|
||||
|
||||
file { '/srv/static/mirror/web':
|
||||
file { "${data_directory}/web":
|
||||
ensure => directory,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
require => File['/srv/static/mirror'],
|
||||
}
|
||||
|
||||
::httpd::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'],
|
||||
require => File["${data_directory}"],
|
||||
}
|
||||
|
||||
package { 'bandersnatch':
|
||||
@ -49,7 +25,7 @@ class openstack_project::pypi_mirror (
|
||||
|
||||
file { '/etc/bandersnatch.conf':
|
||||
ensure => present,
|
||||
source => 'puppet:///modules/openstack_project/bandersnatch.conf',
|
||||
content => template('openstack_project/bandersnatch.conf.erb'),
|
||||
}
|
||||
|
||||
file { '/var/log/bandersnatch':
|
||||
|
@ -1,6 +1,6 @@
|
||||
[mirror]
|
||||
; The directory where the mirror data will be stored.
|
||||
directory = /srv/static/mirror
|
||||
directory = <%= @data_directory %>
|
||||
|
||||
; The PyPI server which will be mirrored.
|
||||
; master = https://testpypi.python.org
|
Loading…
Reference in New Issue
Block a user