Merge "Separate concerns in pypi_mirror.pp"

This commit is contained in:
Jenkins 2015-12-23 16:55:28 +00:00 committed by Gerrit Code Review
commit 78b728f75c
3 changed files with 35 additions and 31 deletions

View File

@ -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'],
}
}

View File

@ -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':

View File

@ -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