Add NPM mirror hosting to unified mirrors
This patch makes the necessary modifications to host npm packages on our mirrors. Changes include: - index.json as a DirectoryIndex - Rewrite rules for the AFS folder structure - mod_substitute invocation to correctly reference absolute tarball url's described in the index.json files. Change-Id: I1a5d560068e37e20ec565b8d864f89732ff5ad74
This commit is contained in:
parent
80cd50c593
commit
320c399a91
@ -7,6 +7,7 @@ class openstack_project::mirror (
|
||||
$mirror_root = '/afs/openstack.org/mirror'
|
||||
$pypi_root = "${mirror_root}/pypi"
|
||||
$wheel_root = "${mirror_root}/wheel"
|
||||
$npm_root = "${mirror_root}/npm"
|
||||
|
||||
$www_base = '/var/www'
|
||||
$www_root = "${www_base}/mirror"
|
||||
@ -61,6 +62,16 @@ class openstack_project::mirror (
|
||||
]
|
||||
}
|
||||
|
||||
file { "${www_root}/npm":
|
||||
ensure => link,
|
||||
target => "${npm_root}",
|
||||
owner => root,
|
||||
group => root,
|
||||
require => [
|
||||
File["${www_root}"],
|
||||
]
|
||||
}
|
||||
|
||||
file { "${www_root}/robots.txt":
|
||||
ensure => present,
|
||||
owner => 'root',
|
||||
@ -80,6 +91,12 @@ class openstack_project::mirror (
|
||||
}
|
||||
}
|
||||
|
||||
if ! defined(Httpd::Mod['substitute']) {
|
||||
httpd::mod { 'substitute':
|
||||
ensure => present,
|
||||
}
|
||||
}
|
||||
|
||||
::httpd::vhost { $vhost_name:
|
||||
port => 80,
|
||||
priority => '50',
|
||||
|
@ -42,6 +42,22 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %>
|
||||
RewriteCond %{DOCUMENT_ROOT}/wheel/$1/$2/$2$3 -d
|
||||
RewriteRule ^/wheel/([^/]+)/([^/])([^/]*)(/.*)?$ /wheel/$1/$2/$2$3$4 [L]
|
||||
|
||||
<Directory <%= @docroot %>/npm/>
|
||||
DirectoryIndex index.json
|
||||
|
||||
# npm's URL's are:
|
||||
# /npm/-/index.json
|
||||
# /npm/a/aabc/index.json
|
||||
# /npm/a/aabc/latest/index.json
|
||||
# /npm/a/aabc/-/aabc-0.0.0.tgz
|
||||
RewriteCond %{REQUEST_URI} ^/npm/([^/])([^/]*)
|
||||
RewriteCond %{DOCUMENT_ROOT}/npm/$1/$1$2 -d
|
||||
RewriteRule ^([^/])([^/]*)(/.*)?$ $1/$1$2$3 [L]
|
||||
|
||||
AddOutputFilterByType SUBSTITUTE application/json
|
||||
Substitute "s|http://localhost|http://<%= @srvname %>/npm|ni"
|
||||
</Directory>
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user