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

Conversation

ehelms
Copy link
Member

@ehelms ehelms commented Aug 13, 2023

No description provided.

@ehelms
Copy link
Member Author

ehelms commented Aug 13, 2023

This would create the vhost but there is the question of how the content gets to the Vhost. In the case of Koji, web01 rsyncs the repositories to it via a special script.

In the case of Copr, where we are generating the repositories on a Jenkins node, I do not think that strategy will work. I think we would need to scp the repositories to web01 in that case. I don't think we do anything like this today to model this after exactly. My open questions:

  1. Is SCP the right way to transfer?
  2. How do we lock web01 down to just allow this SCP action when initiated from the Jenkins node?

@evgeni
Copy link
Member

evgeni commented Aug 15, 2023

This would create the vhost but there is the question of how the content gets to the Vhost. In the case of Koji, web01 rsyncs the repositories to it via a special script.

In the case of Copr, where we are generating the repositories on a Jenkins node, I do not think that strategy will work. I think we would need to scp the repositories to web01 in that case. I don't think we do anything like this today to model this after exactly. My open questions:

1. Is SCP the right way to transfer?
2. How do we lock web01 down to just allow this SCP action when initiated from the Jenkins node?

(if anyone wants to see the "special" script, it's this one: https://github.com/theforeman/foreman-infra/blob/master/puppet/modules/web/files/deploy-yumrepo.sh )

I think rsync-over-SSH is the right answer, because we already have infrastructure for that in place (Debian uses that to push the built packages from the builders to web01). See https://github.com/theforeman/foreman-infra/blob/master/puppet/modules/web/manifests/vhost/deb.pp and https://github.com/theforeman/foreman-infra/blob/master/puppet/modules/web/manifests/vhost/stagingdeb.pp

@ehelms ehelms force-pushed the add-stagingyum branch 3 times, most recently from 9856e7f to 8067cb2 Compare August 15, 2023 19:45
@ehelms
Copy link
Member Author

ehelms commented Aug 15, 2023

Let's see if I got the hang of this with this update. I've also opened up a draft for the Jenkins job in order to align the changes necessary to pull this workflow off (theforeman/jenkins-jobs#349).

If I understand this correctly, initiating an rsync from Jenkins will actually initiate the deploy-stagingyum.sh script, where it will do the rsync to a temporary location and then copy it to the deployed location on web01.

This change will require me to create a user via our Foreman? Or just an SSH key? I assume this gets created via some action in Foreman but then will need to be added to Jenkins.

@evgeni
Copy link
Member

evgeni commented Aug 17, 2023

this is missing something like

diff --git puppet/modules/profiles/manifests/web.pp puppet/modules/profiles/manifests/web.pp
index 9383587a..8fa6fa8d 100644
--- puppet/modules/profiles/manifests/web.pp
+++ puppet/modules/profiles/manifests/web.pp
@@ -60,4 +60,9 @@ class profiles::web (
     rsync_max_connections => $rsync_max_connections,
   }
   contain web::vhost::yum
+
+  class { 'web::vhost::stagingyum':
+    stable                => $stable,
+  }
+  contain web::vhost::stagingyum
 }

to actually load that class

@evgeni
Copy link
Member

evgeni commented Aug 17, 2023

overall, this is working

(tested by a vagrant up web with the above patch, then generating a key and using it in ~yumrepostage/.ssh/authorized_keys like this:

command="/home/yumrepostage/bin/secure_yumrepostage" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3AhxArA3lkxcFuSMsf2UMCyNyHHKC/aTiist7L3zQCeEb55jAMsDi1ZjnQou07TWuhqayPmeEF3gUGp5SeRjUTJu+6AkSA9zsh1bY5akOboYU4WGlRkspSiBCLbzevJNvAuDGRYH/fLyadIRGHKweXRCiIYglDhEuBrVf8E3u33NLCgloj848mhFTAEiKt+UBlfvQqcKsGwA7hE6pIOgSVKkApIsgR0Bv7Bn7QSgn5bbhVWd8zpAten3+LYOTaFTIvypc6qu3Px814K1XdWYvtm6+S4rGkfq8LPE6VWo6k/+8F1VH8bGIA3e1RMn99kNvFgpL3wxp0V6wsCEj4Qj1 root@web

and then doing an rsync manually

@ehelms ehelms marked this pull request as ready for review August 18, 2023 20:07
puppet/modules/profiles/manifests/web.pp Outdated Show resolved Hide resolved

secure_ssh::receiver_setup { $user:
user => $user,
foreman_search => '(name = external_ip4 or name = external_ip6)',
Copy link
Member

Choose a reason for hiding this comment

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

Probably still good to limit this to Jenkins nodes instead of all machines. You can probably limit it to host ~ node*.jenkins.*.theforeman.org. You can test it out in Foreman since it's just going a search on fact_values.

Though I do worry about pagination:

$ip_data = foreman::foreman('fact_values', $foreman_search, '20', lookup('foreman_url'), $api_user, $api_pass)

Copy link
Member Author

Choose a reason for hiding this comment

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

There is only 11 nodes, so I think we are OK and this search works.

Copy link
Member

Choose a reason for hiding this comment

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

If all have both IPv4 and IPv6 then 11 * 2 = 22, so we'd miss 2 IPs. Today we're OK because not all nodes are dual stack.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. And this current definition keeps it in line with the yum vhost as well:

https://github.com/theforeman/foreman-infra/blob/master/puppet/modules/web/manifests/vhost/yum.pp#L31-L35

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I think this is correct now.


secure_ssh::rsync::uploader_key { 'yumstage':
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.

@ehelms ehelms merged commit 15844e7 into theforeman:master Aug 23, 2023
2 checks passed
@ehelms
Copy link
Member Author

ehelms commented Aug 24, 2023

I seem to be getting permission denied from Jenkins to web01:

08:26:07  + export 'RSYNC_RSH=ssh -i /home/jenkins/workspace/staging_key/rsync_yumstage_key'
08:26:07  + RSYNC_RSH='ssh -i /home/jenkins/workspace/staging_key/rsync_yumstage_key'
08:26:07  + /usr/bin/rsync -avPx foreman/nightly [email protected]:rsync_cache/foreman/nightly
08:26:08  Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants