Added pypi hosting for AFS mirror slave

This patch adds a vhost that exposes /afs/openstack.org/mirror/pypi/web
to the internet under <hostname>/pypi. It also adds a do-not-follow
robots.txt file.

Change-Id: I3d7629d80fe1e8762344852fab4a942bc476b706
This commit is contained in:
Michael Krotscheck 2016-01-21 10:53:20 -08:00
parent c009700ca4
commit 168eab95d8
2 changed files with 86 additions and 0 deletions

View File

@ -5,5 +5,54 @@ class openstack_project::mirror (
) {
$mirror_root = '/afs/openstack.org/mirror'
$pypi_root = "${mirror_root}/pypi"
$www_root = '/var/www/mirror'
#####################################################
# Build Apache Webroot
file { "${www_root}":
ensure => directory,
owner => root,
group => root,
}
# Create the symlink to pypi.
file { "${www_root}/pypi":
ensure => link,
target => "${pypi_root}/web",
owner => root,
group => root,
require => [
File["${www_root}"],
]
}
file { "${www_root}/robots.txt":
ensure => present,
owner => 'root',
group => 'root',
mode => '0444',
source => 'puppet:///modules/openstack_project/disallow_robots.txt',
require => File["${www_root}"],
}
#####################################################
# Build VHost
include ::httpd
if ! defined(Httpd::Mod['rewrite']) {
httpd::mod { 'rewrite':
ensure => present,
}
}
::httpd::vhost { $vhost_name:
port => 80,
priority => '50',
docroot => "${www_root}",
template => 'openstack_project/mirror.vhost.erb',
require => [
File["${www_root}"],
]
}
}

View File

@ -0,0 +1,37 @@
# ************************************
# Managed by Puppet
# ************************************
NameVirtualHost <%= @vhost_name %>:<%= @port %>
<VirtualHost <%= @vhost_name %>:<%= @port %>>
ServerName <%= @srvname %>
<% if @serveraliases.is_a? Array -%>
<% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
<% elsif @serveraliases != nil -%>
<%= " ServerAlias #{@serveraliases}" -%>
<% end -%>
DocumentRoot <%= @docroot %>
<Directory <%= @docroot %>>
Options <%= @options %>
AllowOverride None
Order allow,deny
allow from all
Satisfy any
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
# Pypi URL's are:
# /pypi/simple/a/a/a-etc.whl
# /pypi/simple/a/abcd/abcd-etc.whl
# /pypi/simple/a/abcde/abcde-etc.whl
RewriteEngine On
RewriteRule ^/pypi/simple/([^/])([^/]*)$ /pypi/simple/$1/$1$2 [L]
RewriteRule ^/pypi/simple/([^/])([^/]*)/(.*)$ /pypi/simple/$1/$1$2/$3 [L]
ErrorLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/<%= @name %>_error.log
LogLevel warn
CustomLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/<%= @name %>_access.log combined
ServerSignature Off
</VirtualHost>