Skip to content

Commit

Permalink
Add stagingyum vhost to web01 for Copr staging repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Aug 23, 2023
1 parent cb1a9c7 commit d91e627
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
2 changes: 2 additions & 0 deletions puppet/modules/profiles/manifests/web.pp
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@
rsync_max_connections => $rsync_max_connections,
}
contain web::vhost::yum

contain web::vhost::stagingyum
}
2 changes: 2 additions & 0 deletions puppet/modules/slave/manifests/packaging.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
class { 'slave::packaging::rpm':
homedir => $homedir,
koji_certificate => $koji_certificate,
user => 'jenkins',
workspace => $workspace,
}
contain slave::packaging::rpm
}
Expand Down
8 changes: 8 additions & 0 deletions puppet/modules/slave/manifests/packaging/rpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class slave::packaging::rpm (
Stdlib::Absolutepath $homedir,
Optional[String] $koji_certificate = undef,
String $user,
Stdlib::Absolutepath $workspace,
) {
# TODO: Fix on EL8 and get rid of this
$is_el8 = $facts['os']['release']['major'] == '8'
Expand Down Expand Up @@ -114,4 +116,10 @@
package { ['dnf', 'dnf-plugins-core']:
ensure => present,
}

secure_ssh::rsync::uploader_key { 'yumstage':
user => $user,
dir => "${workspace}/staging_key",
manage_dir => true,
}
}
53 changes: 53 additions & 0 deletions puppet/modules/web/manifests/vhost/stagingyum.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# @summary Set up the yum vhost
# @api private
class web::vhost::stagingyum (
Stdlib::Fqdn $servername = 'stagingyum.theforeman.org',
Stdlib::Absolutepath $yum_directory = '/var/www/vhosts/stagingyum/htdocs',
String $user = 'yumrepostage',
) {
$yum_directory_config = [
{
path => $yum_directory,
options => ['Indexes', 'FollowSymLinks', 'MultiViews'],
expires_active => 'on',
expires_default => 'access plus 2 minutes',
},
{
path => '.+\.(bz2|gz|rpm|xz)$',
provider => 'filesmatch',
expires_active => 'on',
expires_default => 'access plus 30 days',
},
{
path => 'repomd.xml',
provider => 'files',
expires_active => 'on',
expires_default => 'access plus 2 minutes',
},
]

secure_ssh::receiver_setup { $user:
user => $user,
foreman_search => 'host ~ node*.jenkins.*.theforeman.org and (name = external_ip4 or name = external_ip6)',
script_content => template('web/deploy-stagingyum.sh.erb'),
}

web::vhost { 'stagingyum':
servername => $servername,
docroot => $yum_directory,
docroot_owner => $user,
docroot_group => $user,
docroot_mode => '0755',
directories => $yum_directory_config,
}

['HEADER.html', 'robots.txt'].each |$filename| {
file { "${yum_directory}/${filename}":
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => file("web/yum/${filename}"),
}
}
}
11 changes: 11 additions & 0 deletions puppet/modules/web/templates/deploy-stagingyum.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Make sure target dir can be created
YUM_PATH=`echo "${SSH_ORIGINAL_COMMAND}" | awk '{ print $NF }'`
PROJECT=`echo $YUM_PATH | /bin/cut -f2 -d/`
RELEASE=`echo $YUM_PATH | /bin/cut -f3 -d/`
mkdir -p <%= @home %>/rsync_cache/$PROJECT/$RELEASE

# Permit transfer
$SSH_ORIGINAL_COMMAND

# Publish the site - stderr/out redirect is required to stop the noninteractive shell from hanging
rsync -rvx --delete-after <%= @home %>/rsync_cache/$PROJECT/$RELEASE <%= @yum_directory %>/ 2>&1 >/dev/null ;

0 comments on commit d91e627

Please sign in to comment.