Forge Home

yumrepos_fact

Custom fact that shows the count of yumrepos.

9,137 downloads

314 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 3.0.0 (latest)
  • 2.1.0
  • 2.0.0
  • 1.0.0
  • 0.2.1
  • 0.2.0
  • 0.1.0
released Jan 19th 2023
This version is compatible with:
  • Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x
  • Puppet >= 6.0.0 < 8.0.0
  • , , , , , , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'nate-yumrepos_fact', '3.0.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add nate-yumrepos_fact
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install nate-yumrepos_fact --version 3.0.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

nate/yumrepos_fact — version 3.0.0 Jan 19th 2023

Puppet Forge Build Status

Yumrepo Fact

This module adds a custom Facter fact that shows the number of enabled and/or disabled yum repositories on RedHat-like servers.

[root@centos7 ~]# facter -p yumrepos
{
  enabled => [
    "base",
    "updates",
    "dev_apps",
    "puppet_enterprise"
  ],
  disabled => [
    "base-source",
    "updates-source",
    "extras",
    "extras-source",
    "fasttrack"
  ],
  count => {
    enabled => 4,
    disabled => 5,
    total => 9
  }
}

Example Usage

$number_of_repos = $facts['yumrepos']['count']['total']

file { '/etc/motd':
  ensure  => file,
  content => "This node has ${number_of_repos} yum repos on it."
}
if 'corportate-repo' in $facts['yumrepos']['enabled'] {
  package { 'foo': ensure => present }
} else {
  package { 'bar': ensure => present }
}

Inventory and Reporting Examples

The yumrepos fact can be queried out of PuppetDB to do basic inventory or reporting.

# Show the value of the yumrepos fact on all nodes.
puppet query 'facts[certname, value] { name = "yumrepos" }'

Reference

The output of the fact is a hash that contains the following keys:

  • enabled: An array of the names of enabled repos.
  • disabled: An array of the names of disabled repos.
  • count: A hash that contains the following sub keys:
    • enabled: Integer - number of enabled repos.
    • disabled: Integer - number of disabled repos.
    • total: Integer - total number of repos.

How it works

This fact uses Puppet's resource abstraction layer to list all the local yumrepo resources on a node. Effectively, this fact is doing a puppet resource yumrepo and parsing the enabled attribute to determine if a repo is enabled or not.

The name of each yum repo is coming from the title of the relevant yumrepo resource type.

Another way to view yum repos is with the command, yum repolist. I chose not to use that because that would mean shelling out to a system command rather than staying in Ruby land. I haven't done any benchmarking, but I'm guessing it's faster this way.

Contributing and Development

Pull requests are always welcomed!

This module uses the Puppet Development Kit and Litmus for validation and acceptance testing. All pull requests must pass the GitHub Actions checks before they can be merged.

For local development, here's the workflow I use and what I recommend you use as well:

  1. Create a feature branch.

  2. Make your changes.

  3. Update any docs or README's if user-facing things change.

  4. Validate syntax and style: pdk validate

  5. Run local Litmus acceptance tests (note: this requies a functioning local Docker installation):

    pdk bundle exec rake 'litmus:provision[docker, centos:7]'
    pdk bundle exec rake 'litmus:install_agent[puppet]'
    pdk bundle exec rake 'litmus:install_module'
    pdk bundle exec rake 'litmus:acceptance:parallel'
    pdk bundle exec rake 'litmus:tear_down'
    
  6. Push up your branch to your fork and make a Pull Request.