From 168eab95d8eff2006984153182b0ea966e40ba76 Mon Sep 17 00:00:00 2001 From: Michael Krotscheck Date: Thu, 21 Jan 2016 10:53:20 -0800 Subject: [PATCH] Added pypi hosting for AFS mirror slave This patch adds a vhost that exposes /afs/openstack.org/mirror/pypi/web to the internet under /pypi. It also adds a do-not-follow robots.txt file. Change-Id: I3d7629d80fe1e8762344852fab4a942bc476b706 --- modules/openstack_project/manifests/mirror.pp | 49 +++++++++++++++++++ .../templates/mirror.vhost.erb | 37 ++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 modules/openstack_project/templates/mirror.vhost.erb diff --git a/modules/openstack_project/manifests/mirror.pp b/modules/openstack_project/manifests/mirror.pp index 647941e4d3..b93e4e3367 100644 --- a/modules/openstack_project/manifests/mirror.pp +++ b/modules/openstack_project/manifests/mirror.pp @@ -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}"], + ] + } } diff --git a/modules/openstack_project/templates/mirror.vhost.erb b/modules/openstack_project/templates/mirror.vhost.erb new file mode 100644 index 0000000000..b9dc6e9f42 --- /dev/null +++ b/modules/openstack_project/templates/mirror.vhost.erb @@ -0,0 +1,37 @@ +# ************************************ +# Managed by Puppet +# ************************************ + +NameVirtualHost <%= @vhost_name %>:<%= @port %> +:<%= @port %>> + ServerName <%= @srvname %> + <% if @serveraliases.is_a? Array -%> + <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> + <% elsif @serveraliases != nil -%> + <%= " ServerAlias #{@serveraliases}" -%> + <% end -%> + DocumentRoot <%= @docroot %> + > + Options <%= @options %> + AllowOverride None + Order allow,deny + allow from all + Satisfy any + = 2.4> + Require all granted + + + + # 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 + \ No newline at end of file