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

Fixes #10052 - Code to setup rhsm.conf for atomic hosts #67

Merged
merged 1 commit into from
Feb 22, 2016

Conversation

parthaa
Copy link
Contributor

@parthaa parthaa commented Sep 11, 2015

Atomic hosts don't deal with Rpms. This script provides an alternative way to setup the rhsm.conf by including the cert + rpm post script as a separate entity. It also generates a katello-rhsm-atomic-consumer.tar.gz , which has this. So the user is expected download the tar gz , extract, cd into atomic and then run "katello-rhsm-atomic-consumer" script for it to setup rhsm.conf .

@ehelms
Copy link
Member

ehelms commented Sep 12, 2015

What is different about the atomic reconfigure from the existing reconfigure script?

Thoughts on deploying a script that machines download and run that fetches the cert and reconfigure script and then runs them? I imagine this process will be scripted anyway so we could just handle that directly.

@parthaa
Copy link
Contributor Author

parthaa commented Sep 14, 2015

What is different about the atomic reconfigure from the existing reconfigure script?

Some differences.

  1. We know that the newer version of subscription manager is available on atomic so we dont need to do a "rpm -q .." and figure out version of subs manager. Moreover rpm command is not available on atomic so the script will fail right away if we try to do "rpm -q".
  2. The source directory for the katello ca cert is different in the case of rpm. In the case of the atomic the ca cert is going to be available is in a different place.

But I understand your concern that it will add 2 places to maintain this logic.. Any suggestions on combining? Concat would be hard, would be better if I could do includes or variable magic.

Thoughts on deploying a script that machines download and run that fetches the cert and reconfigure script and then runs them? I imagine this process will be scripted anyway so we could just handle that directly.

So I noticed that I would have to add a "--insecure" every time I did a wget. I felt it would be better user experience to say, download this tar gz and have the script use the files in that extracted directory. In other word the tar gz would be the equivalent of the rpm and the script inside it would be the equivalent of the post script.

@ehelms
Copy link
Member

ehelms commented Sep 14, 2015

On Mon, Sep 14, 2015 at 12:03 PM, Partha Aji [email protected]
wrote:

What is different about the atomic reconfigure from the existing
reconfigure script?

Some differences.

  1. We know that the newer version of subscription manager is available on
    atomic so we dont need to do a "rpm -q .." and figure out version of subs
    manager. Moreover rpm command is not available on atomic so the script will
    fail right away if we try to do "rpm -q".
  2. The source directory for the katello ca cert is different in the case
    of rpm. In the case of the atomic the ca cert is going to be available is
    in a different place.

But I understand your concern that it will add 2 places to maintain this
logic.. Any suggestions on combining? Concat would be hard, would be better
if I could do includes or variable magic.

I think checks within the script would be better than maintaining two whole
versions of it. Could you detect the presence of 'rpm' with which?

Thoughts on deploying a script that machines download and run that fetches
the cert and reconfigure script and then runs them? I imagine this process
will be scripted anyway so we could just handle that directly.

So I noticed that I would have to add a "--insecure" every time I did a
wget. I felt it would be better user experience to say, download this tar
gz and have the script use the files in that extracted directory. In other
word the tar gz would be the equivalent of the rpm and the script inside it
would be the equivalent of the post script.

Do you not have to add '--insecure' when retrieving the tar.gz? Difference
with the RPM is that the script gets run automatically -- install RPM with
one command and you are done. This requires a few steps that I imagine
would get scripted anyway so I question whether we ought to just automate
it down to one script to begin with?


Reply to this email directly or view it on GitHub
#67 (comment).

Eric D. Helms
Red Hat Engineering
Ph.D. Student - North Carolina State University

@parthaa
Copy link
Contributor Author

parthaa commented Sep 14, 2015

Do you not have to add '--insecure' when retrieving the tar.gz? Difference
with the RPM is that the script gets run automatically -- install RPM with
one command and you are done. This requires a few steps that I imagine
would get scripted anyway so I question whether we ought to just automate
it down to one script to begin with?

I am not sure I get this. Here is the proposed workflow

$ wget --no-check-certificate http://<sat fqdn>/pub/katello-rhsm-atomic-consumer.tar.gz  
$ tar zxf katello-rhsm-atomic-consumer.tar.gz 
$ cd atomic
$ ./katello-rhsm-atomic-consumer

That tar gz has all the certs and other potential future rpm artifacts that may be needed so that I don't need the script do -> wget --no-check-certificate http:///pub/katello-ca.crt (I am more concerned with adding a --no-check for every wget.)

@ehelms
Copy link
Member

ehelms commented Sep 14, 2015

On Mon, Sep 14, 2015 at 2:03 PM, Partha Aji [email protected]
wrote:

Do you not have to add '--insecure' when retrieving the tar.gz? Difference
with the RPM is that the script gets run automatically -- install RPM with
one command and you are done. This requires a few steps that I imagine
would get scripted anyway so I question whether we ought to just automate
it down to one script to begin with?

I am not sure I get this. Here is the proposed workflow

$ wget --no-check-certificate http:///pub/katello-rhsm-atomic-consumer.tar.gz
$ tar zxf katello-rhsm-atomic-consumer.tar.gz
$ cd atomic
$ ./katello-rhsm-atomic-consumer

That tar gz has all the certs and other potential future rpm artifacts
that may be needed so that I don't need the script do -> wget
--no-check-certificate http:///pub/katello-ca.crt

What am I asking is, why wouldn't this workflow work:

$ wget --no-check-certificate http:///pub/katello-ca-consumer-latest.sh
$ ./katello-ca-consumer-latest.sh

You had mentioned RPM isn't available on an atomic host, are we guaranteed
that tar and gunzip are as well?

Reply to this email directly or view it on GitHub
#67 (comment).

Eric D. Helms
Red Hat Engineering
Ph.D. Student - North Carolina State University

@parthaa
Copy link
Contributor Author

parthaa commented Sep 14, 2015

What am I asking is, why wouldn't this workflow work:

It may work. I just feel its more convinient and consistent with the way we do rpm + script to have it packaged as tar gz

@jlsherrill
Copy link
Contributor

I think we were hesitant to write a script that downloads the ca file insecurely. Leaving it up to the user to transfer the tar file means both the script and the ca make it to the box. Also there is really no need to gzip the file if that is a concern. Just tar'ing it is sufficient.

@mccun934
Copy link
Contributor

I'm in favor of anything that reduces the steps for the user to a 1-2 liner statement if possible.

You could even reduce it to:

curl http:///pub/katello-ca-consumer-latest.sh | sudo bash

keep in mind, wget isn't always installed by default in RHEL/CentOS, curl/tar/gzip are so rely on curl when you can

@ehelms
Copy link
Member

ehelms commented Sep 14, 2015

Tar or not it's still generally insecure unless they go outside of http to
transfer?
On Sep 14, 2015 3:17 PM, "Mike McCune" [email protected] wrote:

I'm in favor of anything that reduces the steps for the user to a 1-2
liner statement if possible.

You could even reduce it to:

curl http:///pub/katello-ca-consumer-latest.sh | sudo bash

keep in mind, wget isn't always installed by default in RHEL/CentOS,
curl/tar/gzip are so rely on curl when you can


Reply to this email directly or view it on GitHub
#67 (comment).

@parthaa
Copy link
Contributor Author

parthaa commented Sep 15, 2015

What is different about the atomic reconfigure from the existing reconfigure script?

Thoughts on deploying a script that machines download and run that fetches the cert and reconfigure script and then runs them? I imagine this process will be scripted anyway so we could just handle that directly.

I tried very hard on this and almost had it working except for this stupid change in the subs manager command
Atomic Version

subscription-manager config \
  --server.hostname="$KATELLO_SERVER" \
  --server.prefix="$PREFIX" \
  --server.port="$PORT" \
  --rhsm.repo_ca_cert="%(ca_cert_dir)s$KATELLO_CERT" \
  --rhsm.baseurl="$BASEURL"

vs

RPM Version

subscription-manager config \
  --server.hostname="$KATELLO_SERVER" \
  --server.prefix="$PREFIX" \
  --server.port="$PORT" \
  --rhsm.repo_ca_cert="%%(ca_cert_dir)s$KATELLO_CERT" \
  --rhsm.baseurl="$BASEURL"

Notice the extra % in --rhsm.repo_ca_cert (extra % necessary because its an rpm post script)

@ehelms
Copy link
Member

ehelms commented Sep 16, 2015

Ahh, bummer, maybe two is the proper way due to these subtleties :/ Could you re-work the declarations in katello.pp so that the atomic chain of types is not intermixed throughout the RPM side of things?

@parthaa
Copy link
Contributor Author

parthaa commented Sep 16, 2015

Could you re-work the declarations in katello.pp so that the atomic chain of types is not intermixed throughout the RPM side of things?

Could you please expand on your comments here, I am trying to figure out what exactly you want me to change. I thought katello.pp was the place put everything that goes on in pub.

@parthaa
Copy link
Contributor Author

parthaa commented Sep 22, 2015

Could you re-work the declarations in katello.pp so that the atomic chain of types is not intermixed throughout the RPM side of things?

@ehelms addressed

@@ -46,5 +54,35 @@
bootstrap_script => template('certs/rhsm-katello-reconfigure.erb'),
alias => $candlepin_cert_rpm_alias,
subscribe => $::certs::server_ca,
} ~>
Copy link
Member

Choose a reason for hiding this comment

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

This still ties the atomic workflow to the certs_bootstrap_rpm, I think it would be better to break this dependency and let the atomic stuff stand alone i.e. change this line to } and insert a blank line.

@parthaa
Copy link
Contributor Author

parthaa commented Feb 14, 2016

@ehelms @stbenjam @jlsherrill @bbuckingham updating this as per our discussion.

Main intent of this commit is to setup rhsm conf on an atomic host to
setup consumer registration (a role similar to the one played by the
consumer bootstrap rpm).

Artifacts produced

  1. /var/www/html/pub/katello-rhsm-consumer on the satellite. This script
    contains the code needed to setup rhsm conf on both atomic as well as
    non atomic machines. The contents of this script came out of the template
    used for post install script in the bootstrap consumer rpm. It has been
    tuned to work for both atomic/non-atomic machines

  2. Update to the bootstrap rpm to copy the new script to /usr/bin and
    run that as a part of post install.

@parthaa parthaa force-pushed the atomic-register branch 7 times, most recently from 4c5f21c to 5396f91 Compare February 14, 2016 23:55
$candlepin_consumer_name = "katello-ca-consumer-${::fqdn}"
$candlepin_consumer_summary = "Subscription-manager consumer certificate for Katello instance ${::fqdn}"
$candlepin_consumer_description = 'Consumer certificate and post installation script that configures rhsm.'

$katello_default_ca_data = file("${certs::pki_dir}/certs/${certs::default_ca_name}.crt")
Copy link
Member

Choose a reason for hiding this comment

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

You'd want to reference certs::katello::default_ca_name

@parthaa parthaa force-pushed the atomic-register branch 2 times, most recently from 2ce2a8f to 7d798b1 Compare February 15, 2016 19:00
@parthaa
Copy link
Contributor Author

parthaa commented Feb 15, 2016

@ehelms, @bbuckingham green!

@bbuckingham
Copy link
Member

@parthaa, I tested this out on my katello-devel environment with an atomic host and it is behaving perfectly. The full flow that i did was:

  • import manifest w/ RH OStree content
  • enable repo & sync OStree repo
  • create content view - add repo to it, publish it, promote it
  • create activation key - associate lifecycle environment, content view and subscriptions
  • installed a rhel atomic host
  • downloaded the katello-rhsm-consumer from katello (this step and the ones that follow are the important ones wrt the cert)
  • subscription-manager register the host to katello
  • performed basic sanity testing of atomic host (e.g. atomic host status, upgrade, ...etc)

Note: i haven't verified a RHEL7 host (non-atomic) yet, but plan to try that as well.

@bbuckingham
Copy link
Member

@parthaa, I ran a test with a RHEL 7 vagrant host. I was able to download/install the bootstrap rpm, register the host, subscribe to custom content and download RPMs from katello.

@bbuckingham
Copy link
Member

@parthaa, ACK from me; however, I'd recommend that also get ACK from an additional dev that is more familiar with the puppet-certs module.

@ehelms
Copy link
Member

ehelms commented Feb 19, 2016

I'll take a quick pass today

@ehelms
Copy link
Member

ehelms commented Feb 19, 2016

Testing this against a fresh installation, I immediately run into the following:

[ERROR 2016-02-19 10:29:53 verbose]  Could not find any files from /etc/pki/katello/certs/katello-default-ca.crt at /usr/share/katello-installer/modules/certs/manifests/katello.pp:25 on node nightly.example.com

@bbuckingham
Copy link
Member

@ehelms, Good catch! My install was a dev install where I re-applied the puppet-certs update and re-ran the katello-installer-devel. (i.e. testing in a clean, but pre-existing environment)

@parthaa
Copy link
Contributor Author

parthaa commented Feb 19, 2016

@ehelms updated. If you can figure out a way to get custom types to work with my template let me know :)

@parthaa
Copy link
Contributor Author

parthaa commented Feb 19, 2016

@ehelms is the change I had to make to address your comment -> https://github.com/Katello/puppet-certs/pull/67/files#diff-aad4d37a11e8099dfec9d8ad8c38dec0R21

$candlepin_consumer_name = "katello-ca-consumer-${::fqdn}"
$candlepin_consumer_summary = "Subscription-manager consumer certificate for Katello instance ${::fqdn}"
$candlepin_consumer_description = 'Consumer certificate and post installation script that configures rhsm.'

$katello_default_ca_file = "${certs::pki_dir}/certs/${certs::katello::default_ca_name}.crt"
$katello_server_ca_file = "${certs::pki_dir}/certs/${certs::katello::server_ca_name}.crt"
Copy link
Member

Choose a reason for hiding this comment

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

This is essentially redefining https://github.com/Katello/puppet-certs/blob/master/manifests/init.pp#L130 which you could just use to DRY this up.

@ehelms
Copy link
Member

ehelms commented Feb 19, 2016

Functionally this worked for me through and install and a regenerate.

Main intent of this commit is to setup rhsm conf on an atomic host to
setup consumer registration (a role similar to the one played by the
consumer bootstrap rpm).

Artifacts produced

1) /var/www/html/pub/katello-rhsm-consumer on the satellite. This script
contains the code needed to setup rhsm conf on both atomic as well as
non atomic machines. The contents of this script came out of the template
used for post install script in the bootstrap consumer rpm. It has been
tuned to work for both atomic/non-atomic machines

2) Update to the bootstrap rpm to copy the new script to /usr/bin and
run that as a part of post install.
@ehelms
Copy link
Member

ehelms commented Feb 22, 2016

ACK - thanks @parthaa

ehelms added a commit that referenced this pull request Feb 22, 2016
Fixes #10052 - Code to setup rhsm.conf for atomic hosts
@ehelms ehelms merged commit 2b897bb into theforeman:master Feb 22, 2016
@parthaa parthaa deleted the atomic-register branch February 22, 2016 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants