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 support for yum facts (similar to the apt ones) #141

Merged
merged 3 commits into from
Apr 12, 2020

Conversation

smortex
Copy link
Member

@smortex smortex commented Jul 19, 2019

Pull Request (PR) description

This PR add a bunch of facts similar to the ones provided by the apt module:

  • yum_has_updatesBoolean indicating if updates are available;
  • yum_package_updatesArray[String] list of upgradable packages;
  • yum_updatesInteger number of upgradable packages;
  • yum_reboot_requiredBoolean indicating if the systems needs to be rebooted.

e.g.

% facter yum_has_updates yum_package_updates yum_reboot_required yum_updates
yum_has_updates => true
yum_package_updates => [
  "puppet-agent.x86_64"
]
yum_reboot_required => true
yum_updates => 1
% facter yum_has_updates yum_package_updates yum_reboot_required yum_updates
yum_has_updates => false
yum_package_updates => []
yum_reboot_required => false
yum_updates => 0

This Pull Request (PR) fixes the following issues

n/a

@smortex smortex force-pushed the yum-list-updates-facts-and-tasks branch 2 times, most recently from 85fc180 to 4169235 Compare July 23, 2019 19:48
@smortex smortex changed the title Add "yum list updates" facts and task Add support for yum facts (similar to the apt ones) Jul 23, 2019
@smortex smortex force-pushed the yum-list-updates-facts-and-tasks branch from 91fbb88 to 9309458 Compare July 23, 2019 20:37
@TJM
Copy link

TJM commented Jul 29, 2019

You might check out the https://forge.puppet.com/albatrossflavour/os_patching module, which already does this sort of thing, but has taken into account the time impact during puppet runs. I would recommend against running yum commands for each facter run.

lib/facter/yum_reboot_required.rb Outdated Show resolved Hide resolved
lib/facter/yum_reboot_required.rb Outdated Show resolved Hide resolved
spec/acceptance/define_versionlock_spec.rb Outdated Show resolved Hide resolved
lib/facter/yum_updates.rb Outdated Show resolved Hide resolved
@smortex smortex force-pushed the yum-list-updates-facts-and-tasks branch 3 times, most recently from 7608397 to 3d90c58 Compare April 10, 2020 05:56
@bastelfreak bastelfreak added enhancement New feature or request tests-fail labels Apr 10, 2020
@ekohl
Copy link
Member

ekohl commented Apr 10, 2020

You might check out the https://forge.puppet.com/albatrossflavour/os_patching module, which already does this sort of thing, but has taken into account the time impact during puppet runs. I would recommend against running yum commands for each facter run.

This is a good thing to keep in mind. I don't know if this reaches out to a subscription service, but we've seen Satellite servers get heavily overloaded when using ensure => latest in large scale deployments.

@smortex
Copy link
Member Author

smortex commented Apr 10, 2020

This is a good thing to keep in mind. I don't know if this reaches out to a subscription service, but we've seen Satellite servers get heavily overloaded when using ensure => latest in large scale deployments.

We deployed it 6 month ago. We contributed patches to fix it / make it work on the various systems we use… Unfortunately it's still "meh" and we are considering to remove it 😞.

@smortex
Copy link
Member Author

smortex commented Apr 10, 2020

I had a local commit for supporting a "list updates" task that I never pushed.

Because of the test failure around the cache and as I suggested in #141 (comment) I added two commits to ensure the repositories are not automatically updated when Puppet runs and to allow refreshing the packages with MCollective / Choria / Bolt.

lib/facter/yum_updates.rb Outdated Show resolved Hide resolved
lib/facter/yum_updates.rb Outdated Show resolved Hide resolved
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.

This looks good to me, but there were other reviewers I'd like to get an approval from since they voiced concerns.

@smortex
Copy link
Member Author

smortex commented Apr 11, 2020

@ekohl sure! There is still the test suite idempotency discussion that is annoying me because I do not understand the intention but I believe it's not testing what it tries… Should we track this in another issue?

Once everybody is happy with the changes, I'd like to squash the commits: I refrained to do it recently because it's a bit painful for reviewers to focus on the changes, but the history does not really makes sense right now 😆

Add three new facts:
- yum_has_updates -- Boolean indicating if updates are available;
- yum_package_updates -- Array[String] list of upgradable packages;
- yum_updates -- Integer number of upgradable packages.

These facts are named in the same way as the ones provided by the
puppetlabs-apt module.
Just like the apt_reboot_required fact provided by the puppetlabs-apt
module, this fact tells if the systems needs to be rebooted.  It relies
on the needs-restarting(1) command which is part of yum-utils, already
managed by the module.
@smortex
Copy link
Member Author

smortex commented Apr 12, 2020

All listed reviewers have approved the change. Let's squash related commits!

@smortex smortex force-pushed the yum-list-updates-facts-and-tasks branch from 64e03cd to 62e055a Compare April 12, 2020 20:58
This task will run yum without -C, fetching recent data if the
repositories are outdated.  The output is processed to extract the
package name, available version and repository of the update.  This
information is provided as an array of hashes.
@smortex smortex force-pushed the yum-list-updates-facts-and-tasks branch from 62e055a to 5abaa60 Compare April 12, 2020 21:06
@dhoppe dhoppe merged commit 79ccdb1 into voxpupuli:master Apr 12, 2020
@smortex smortex deleted the yum-list-updates-facts-and-tasks branch April 12, 2020 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tests-fail
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants