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 a Array[String] argument of repo IDs to be enabled #78

Merged

Conversation

pdemonaco
Copy link
Contributor

Pull Request (PR) description

This request introduces three primary changes

  1. Fact calculation is now constrained to the ['os']['name'] fact instead of the classic 'osfamily' fact. This ensures that the module doesn't waste time running on CentOS or other non RHEL RedHat derivatives.
  2. The custom facts have been combined into a single 'rhsm' custom fact.
  3. A new parameter named enabled_repo_ids has been added to the rhsm class to allow an array of strings.

This Pull Request (PR) fixes the following issues

Rubocop wanted the addition of a few trailing commas on the tests as
they currently exist. Adding these here ensures that they don't clutter my
direct changes.
This commit reworks the main class to accept an array of repo IDs
instead of the original boolean values. Each ID is used as the namevar
of a repo define entity which uses the `subscription-manager repos
--enable` command to activate.
This commit corrects a bug where an undefined repo list would cause the
manifest to fail during compilation.
Corrected the os/family filter so that it works. For some reason the
Facter.value syntax wasn't actually finding the structured
['os']['name'] fact so I had to convert to a ruby block.

Additionally,
the aggregation wasn't correct as the return values from each chunk were
not hashes and therefore couldn't be merged.
Added the new parameter to both the README and the puppet strings. Also
generated a new REFERENCE.md file using the puppetstring function.
@pdemonaco
Copy link
Contributor Author

Huh. Is there a reason that the rubocop configuration for this module expects exactly the opposite behavior for trailing comments than that of the default in pdk validate?

Configure the enabled_repo_ids array to merge unique values when
searching in hiera.
This has been updated to meet the build-requirements defined by travis.
@pdemonaco pdemonaco changed the title Feature/master/repo list argument Add a Array[String] argument of repo IDs to be enabled Sep 17, 2018
.rspec Outdated
--color
--format documentation
Copy link
Member

Choose a reason for hiding this comment

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

why did you change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shoot - I didn't mean to commit that. I converted the module to be PDK compatible for my own local testing during development and I accidentally added this file. PDK changed a ton of stuff and I'm not familiar enough with Travis or the testing configuration in use on this module so I didn't add the other changes. I'll revert this for now.

Copy link
Contributor

@kallies kallies left a comment

Choose a reason for hiding this comment

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

Very valuable changes. They require a new major version of the module in my point of view.

README.md Outdated
@@ -51,6 +51,33 @@ You shouldn't specify the protocol, subscription-manager will use HTTP. For prox

The proxy settings will be used to register the system and as connection option for all the YUM repositories generated in `/etc/yum.repos.d/redhat.repo`

### Enabled Repos

A string array of repo IDs can now be provided as an argument to the class definition. This list will be used to enable the target repos if that has not already occurred.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather say "can be provided" instead of "now".

class { 'rhsm':
rh_user => 'myuser',
rh_password => 'mypassword',
enabled_repo_ids => [
Copy link
Contributor

Choose a reason for hiding this comment

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

I like it!

rh_user => 'myuser',
rh_password => 'mypassword',
enabled_repo_ids => [
'rhel-7-server-rpms',
Copy link
Contributor

Choose a reason for hiding this comment

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

Has this been tested with non-RHEL repositories, e.g. custom repositories on Satellite 6?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately no, I don't have Satellite in my environment so I haven't tested anything like that.

@@ -0,0 +1,26 @@
Facter.add(:rhsm, type: :aggregate) do
Copy link
Contributor

Choose a reason for hiding this comment

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

This fact is a major change. For example, we rely on rhsm_subscription_type for a Satellite 5 to 6 migration.

@@ -12,9 +12,13 @@
# ::rhsm::repo { "rhel-${::operatingsystemmajrelease}-server-extras-rpms": }
define rhsm::repo (
Copy link
Contributor

Choose a reason for hiding this comment

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

empty braces () might be removed.

Copy link
Contributor

@kallies kallies Sep 18, 2018

Choose a reason for hiding this comment

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

Thinking about it again, it would be nice to have a parameter for disabling repositories, too. Or better than nice: we need this functionality but solve it in a additional module. It will simplify the configuration.

This change includes some minor tweaks to the readme file as well as
adding in a build status and puppet version badge.
Added in the original rhsm_repos and rhsm_subscription_type facts for
backward compatibility. These facts are now derived from the new rhsm
structured fact to avoid doubling work.
@pdemonaco
Copy link
Contributor Author

@kallies should I add a version bump in this pull request? I'm assuming by major you mean 4.x.x?

@kallies
Copy link
Contributor

kallies commented Sep 20, 2018

@kallies should I add a version bump in this pull request? I'm assuming by major you mean 4.x.x?

Yes, 4.0.0 would be nice. If there are no braking changes (no fact removal etc.) 3.2.0 is fine for me, too.

@bastelfreak should the version bump be a separate PR?

lib/facter/rhsm.rb Outdated Show resolved Hide resolved
Added an explicit check to the enabled repos facts such that the fact
will only be calculated if the subscription-manager command exists. This
allows the fact to run on CentOS machines which have
subscription-manager installed and prevents errors on those that do not.
An incorrect indendation was left within the enabled_repo_ids chunk when
the test for subscription-manager was moved outside of the chunk. Should
be all set now.
manifests/init.pp Outdated Show resolved Hide resolved
manifests/init.pp Outdated Show resolved Hide resolved
spec/default_facts.yml Outdated Show resolved Hide resolved
@bastelfreak
Copy link
Member

Because of the changed fact this is a breaking change and requires a new major release. You do not need to bump any version here, this will be triggered through the label I applied, during the next release. However, we need to ensure that an upgrade works smoothly for the users. I'm currently not sure how we should properly test it.

@pdemonaco
Copy link
Contributor Author

@bastelfreak is this still backwards incompatible with the re-introduced 'rhsm_' facts? I also converted the confines statement to target the RedHat family again but caused it to skip execution for the list of enabled repos if the subscription-manager binary is missing.

The following corrections are included in this commit:
* enabled_repo_ids is nolonger optional, however, an empty array can be provided
* Legacy syntax left in previous releases has been removed
* PDK conversions which were accidentally committed have been removed
* Compile with all deps is now selected.

## Development

Some general guidelines on PR structure can be found [here](https://voxpupuli.org/docs/#reviewing-a-module-pr).
Copy link
Member

Choose a reason for hiding this comment

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

neat, we should add that to all modules.

manifests/init.pp Outdated Show resolved Hide resolved
@bastelfreak bastelfreak added enhancement New feature or request and removed backwards-incompatible labels Sep 23, 2018
@bastelfreak
Copy link
Member

@pdemonaco you're right, I think this is fine now. Please align the = and afterwards we can merge this.

Alignment of the equal signs on the interface to the primary class.
@bastelfreak bastelfreak merged commit 5fda0b9 into voxpupuli:master Sep 24, 2018
@pdemonaco pdemonaco deleted the feature/master/repo-list-argument branch September 24, 2018 14:36
@pdemonaco
Copy link
Contributor Author

@bastelfreak will this generate a new version on the puppet forge automatically?

@bastelfreak
Copy link
Member

No, we will have to do a new release, maybe in the next few days.

@kallies kallies mentioned this pull request Oct 4, 2018
@ubellavance
Copy link

That looks like an awesome PR! I can't wait to try it (when I find time to do so). Thanks!

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

Successfully merging this pull request may close these issues.

4 participants