2016-01-20 15:11:24 -08:00
|
|
|
# == Class: openstack_project::mirror
|
|
|
|
#
|
|
|
|
class openstack_project::mirror (
|
|
|
|
$vhost_name = $::fqdn,
|
|
|
|
) {
|
|
|
|
|
2017-08-16 10:11:19 +10:00
|
|
|
# Some hosts are mirror01, but we need the host to respond to
|
|
|
|
# "mirror." Re-evaluate this if we end up doing multiple
|
|
|
|
# mirrors/load balancing etc.
|
|
|
|
$alias_name = regsubst($vhost_name, 'mirror\d*\.', 'mirror.')
|
|
|
|
if $alias_name != $vhost_name {
|
|
|
|
$serveraliases = [$alias_name]
|
|
|
|
} else {
|
|
|
|
$serveraliases = undef
|
|
|
|
}
|
|
|
|
|
2017-10-13 13:42:48 +11:00
|
|
|
$mirror_root = '/afs/openstack.org/mirror'
|
2016-01-21 10:57:12 -08:00
|
|
|
$wheel_root = "${mirror_root}/wheel"
|
2016-04-15 15:59:53 -04:00
|
|
|
$ceph_deb_hammer_root = "${mirror_root}/ceph-deb-hammer"
|
2016-05-07 18:37:27 -04:00
|
|
|
$ceph_deb_jewel_root = "${mirror_root}/ceph-deb-jewel"
|
2017-09-27 10:01:13 -04:00
|
|
|
$ceph_deb_luminous_root = "${mirror_root}/ceph-deb-luminous"
|
2018-06-03 23:20:49 +02:00
|
|
|
$ceph_deb_mimic_root = "${mirror_root}/ceph-deb-mimic"
|
2015-12-04 12:09:51 -05:00
|
|
|
$gem_root = "${mirror_root}/gem"
|
2016-01-21 10:57:12 -08:00
|
|
|
|
2016-01-22 16:02:32 -08:00
|
|
|
$www_base = '/var/www'
|
|
|
|
$www_root = "${www_base}/mirror"
|
2016-01-20 15:11:24 -08:00
|
|
|
|
2016-01-21 10:53:20 -08:00
|
|
|
#####################################################
|
|
|
|
# Build Apache Webroot
|
2016-01-22 16:02:32 -08:00
|
|
|
file { "${www_base}":
|
|
|
|
ensure => directory,
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
}
|
|
|
|
|
2016-01-21 10:53:20 -08:00
|
|
|
file { "${www_root}":
|
|
|
|
ensure => directory,
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
2016-01-22 16:02:32 -08:00
|
|
|
require => [
|
|
|
|
File["${www_base}"],
|
|
|
|
]
|
2016-01-21 10:53:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Create the symlink to pypi.
|
2018-11-22 16:14:12 +11:00
|
|
|
# NOTE(ianw) : retired 2018-11-22; see
|
2019-05-09 14:38:02 +00:00
|
|
|
# https://review.opendev.org/#/c/618326/
|
2016-01-21 10:53:20 -08:00
|
|
|
file { "${www_root}/pypi":
|
2018-11-22 16:14:12 +11:00
|
|
|
ensure => absent,
|
2016-01-21 10:53:20 -08:00
|
|
|
}
|
|
|
|
|
2016-01-21 10:57:12 -08:00
|
|
|
# Create the symlink to wheel.
|
|
|
|
file { "${www_root}/wheel":
|
|
|
|
ensure => link,
|
|
|
|
target => "${wheel_root}",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2016-03-07 13:59:56 -05:00
|
|
|
# Create the symlink to centos
|
|
|
|
file { "${www_root}/centos":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/centos",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2016-07-15 11:53:52 -04:00
|
|
|
# Create the symlink to debian
|
|
|
|
file { "${www_root}/debian":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/debian",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-06-26 13:49:16 +10:00
|
|
|
# Create the symlink to debian-security
|
|
|
|
file { "${www_root}/debian-security":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/debian-security",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2016-07-11 10:22:45 -04:00
|
|
|
# Create the symlink to Debian OpenStack Packaging Team reprepro.
|
|
|
|
file { "${www_root}/debian-openstack":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/debian-openstack",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2017-03-30 16:26:38 -04:00
|
|
|
# Create the symlink to rdo
|
|
|
|
file { "${www_root}/rdo":
|
2017-04-09 14:44:11 -04:00
|
|
|
ensure => absent,
|
2017-03-30 16:26:38 -04:00
|
|
|
}
|
|
|
|
|
2016-05-12 11:01:43 -04:00
|
|
|
# Create the symlink to epel
|
|
|
|
file { "${www_root}/epel":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/epel",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-01-24 20:03:42 +00:00
|
|
|
# Create the symlink to yum-puppetlabs
|
|
|
|
file { "${www_root}/yum-puppetlabs":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/yum-puppetlabs",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2016-12-28 15:54:16 -05:00
|
|
|
# Create the symlink to fedora
|
|
|
|
file { "${www_root}/fedora":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/fedora",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2017-02-22 20:43:49 +01:00
|
|
|
# Create the symlink to openSUSE
|
|
|
|
file { "${www_root}/opensuse":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/opensuse",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-02-20 20:17:38 -05:00
|
|
|
# Create the symlink to Ubuntu
|
2016-02-08 11:58:53 -06:00
|
|
|
file { "${www_root}/ubuntu":
|
2016-02-06 09:48:59 -06:00
|
|
|
ensure => link,
|
2016-02-08 11:58:53 -06:00
|
|
|
target => "${mirror_root}/ubuntu",
|
2016-02-06 09:48:59 -06:00
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-02-20 20:17:38 -05:00
|
|
|
# Create the symlink to Ubuntu ports
|
|
|
|
file { "${www_root}/ubuntu-ports":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/ubuntu-ports",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2016-04-15 15:59:53 -04:00
|
|
|
# Create the symlink to ceph-deb-hammer.
|
|
|
|
file { "${www_root}/ceph-deb-hammer":
|
|
|
|
ensure => link,
|
|
|
|
target => "${ceph_deb_hammer_root}",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2016-05-07 18:37:27 -04:00
|
|
|
# Create the symlink to ceph-deb-jewel.
|
|
|
|
file { "${www_root}/ceph-deb-jewel":
|
|
|
|
ensure => link,
|
|
|
|
target => "${ceph_deb_jewel_root}",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2017-09-27 10:01:13 -04:00
|
|
|
# Create the symlink to ceph-deb-luminous.
|
|
|
|
file { "${www_root}/ceph-deb-luminous":
|
|
|
|
ensure => link,
|
|
|
|
target => "${ceph_deb_luminous_root}",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-06-03 23:20:49 +02:00
|
|
|
# Create the symlink to ceph-deb-mimic.
|
|
|
|
file { "${www_root}/ceph-deb-mimic":
|
|
|
|
ensure => link,
|
|
|
|
target => "${ceph_deb_mimic_root}",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2016-06-15 19:45:52 +01:00
|
|
|
# Create the symlink to Ubuntu Cloud Archive.
|
|
|
|
file { "${www_root}/ubuntu-cloud-archive":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/ubuntu-cloud-archive",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2017-04-04 15:23:53 -04:00
|
|
|
# Create the symlink to deb-docker.
|
|
|
|
file { "${www_root}/deb-docker":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/deb-docker",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-01-03 14:50:16 -08:00
|
|
|
# Create the symlink to Ubuntu Puppetlabs.
|
|
|
|
file { "${www_root}/apt-puppetlabs":
|
|
|
|
ensure => link,
|
|
|
|
target => "${mirror_root}/apt-puppetlabs",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2015-12-04 12:09:51 -05:00
|
|
|
file { "${www_root}/gem":
|
|
|
|
ensure => link,
|
|
|
|
target => "${gem_root}",
|
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
require => [
|
2016-04-19 14:51:29 +01:00
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2016-01-21 10:53:20 -08:00
|
|
|
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
|
|
|
|
|
2017-03-29 13:42:29 -07:00
|
|
|
file { '/opt/apache_cache':
|
2017-07-10 17:41:02 +00:00
|
|
|
ensure => absent,
|
2017-08-12 12:07:51 -04:00
|
|
|
force => true,
|
2017-07-10 17:41:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
file { '/var/cache/apache2/proxy':
|
2017-03-29 13:42:29 -07:00
|
|
|
ensure => directory,
|
|
|
|
owner => 'www-data',
|
|
|
|
group => 'www-data',
|
|
|
|
mode => '0755',
|
|
|
|
require => Class['httpd']
|
|
|
|
}
|
|
|
|
|
2016-01-21 10:53:20 -08:00
|
|
|
if ! defined(Httpd::Mod['rewrite']) {
|
|
|
|
httpd::mod { 'rewrite':
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-13 08:30:14 -07:00
|
|
|
if ! defined(Httpd::Mod['substitute']) {
|
|
|
|
httpd::mod { 'substitute':
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-29 13:42:29 -07:00
|
|
|
if ! defined(Httpd::Mod['cache']) {
|
|
|
|
httpd::mod { 'cache':
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! defined(Httpd::Mod['cache_disk']) {
|
|
|
|
httpd::mod { 'cache_disk':
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! defined(Httpd::Mod['proxy']) {
|
|
|
|
httpd::mod { 'proxy':
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-30 11:49:28 -04:00
|
|
|
if ! defined(Httpd::Mod['proxy_http']) {
|
|
|
|
httpd::mod { 'proxy_http':
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-21 10:53:20 -08:00
|
|
|
::httpd::vhost { $vhost_name:
|
|
|
|
port => 80,
|
|
|
|
priority => '50',
|
|
|
|
docroot => "${www_root}",
|
|
|
|
template => 'openstack_project/mirror.vhost.erb',
|
2017-08-16 10:11:19 +10:00
|
|
|
serveraliases => $serveraliases,
|
2016-01-21 10:53:20 -08:00
|
|
|
require => [
|
|
|
|
File["${www_root}"],
|
|
|
|
]
|
|
|
|
}
|
2016-08-18 16:26:18 -04:00
|
|
|
|
2017-04-03 11:06:31 -07:00
|
|
|
# Cache cleanup
|
|
|
|
package { 'apache2-utils':
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
|
|
|
|
cron { 'apache-cache-cleanup':
|
2018-06-14 11:21:31 -07:00
|
|
|
# Clean apache cache once an hour, keep size down to 70GiB.
|
2017-04-03 11:06:31 -07:00
|
|
|
minute => '0',
|
|
|
|
hour => '*',
|
2018-06-14 11:21:31 -07:00
|
|
|
command => 'flock -n /var/run/htcacheclean.lock htcacheclean -n -p /var/cache/apache2/proxy -t -l 70200M > /dev/null',
|
2017-04-03 11:06:31 -07:00
|
|
|
environment => 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',
|
|
|
|
require => [
|
2017-07-10 17:41:02 +00:00
|
|
|
File['/var/cache/apache2/proxy'],
|
2017-04-03 11:06:31 -07:00
|
|
|
Package['apache2-utils'],
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
2016-08-18 16:26:18 -04:00
|
|
|
class { '::httpd::logrotate':
|
|
|
|
options => [
|
|
|
|
'daily',
|
|
|
|
'missingok',
|
|
|
|
'rotate 7',
|
|
|
|
'compress',
|
|
|
|
'delaycompress',
|
|
|
|
'notifempty',
|
|
|
|
'create 640 root adm',
|
|
|
|
],
|
|
|
|
}
|
2016-01-20 15:11:24 -08:00
|
|
|
}
|