Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stagingyum vhost to web01 for Copr staging repositories #1862

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2,6 +2,8 @@
# @api private
class slave::packaging::rpm (
Stdlib::Absolutepath $homedir,
String $user,
Stdlib::Absolutepath $workspace,
Optional[String] $koji_certificate = undef,
) {
# TODO: Fix on EL8 and get rid of this
Expand Down Expand Up @@ -114,4 +116,10 @@
package { ['dnf', 'dnf-plugins-core']:
ensure => present,
}

secure_ssh::rsync::uploader_key { 'yumstage':
ehelms marked this conversation as resolved.
Show resolved Hide resolved
user => $user,
dir => "${workspace}/staging_key",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to note: for other things I've also taken the approach of manually adding this key to Jenkins as a real secret and then use the Jenkins built in functionality. Perhaps worth considering here too.

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 ;