Forge Home

yumrepos_fact

Custom fact that shows the count of yumrepos.

8,989 downloads

257 latest version

4.6 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 Jul 23rd 2017
This version is compatible with:
  • RedHat, CentOS, OracleLinux, Scientific

Start using this module

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

Add this module to your Puppetfile:

mod 'nate-yumrepos_fact', '0.1.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 0.1.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 0.1.0 Jul 23rd 2017

Yumrepo Fact

This module adds a custom fact that shows the following information about locally configured YUM repos on a Puppet agent:

  • Total count of repos
  • Count of enabled repos
  • Count of disabled repos
  • The name of each enabled or disabled repo

Example

[root@centos7 ~]# facter -p yumrepos
{
  enabled => [
    "base",
    "updates",
    "extras",
    "puppet_enterprise"
  ],
  disabled => [
    "centosplus",
    "base-debuginfo",
    "base-source",
    "updates-source",
    "extras-source",
    "C7.1.1503-base",
    "C7.1.1503-updates",
    "C7.1.1503-extras",
    "fasttrack"
  ],
  count => {
    enabled => 4,
    disabled => 9,
    total => 13
  }
}
$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 }

}

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 of local yumrepo resource types on a Puppet agent, as such, Puppet is required for this fact to work. Effectively, this fact is doing a puppet resource yumrepo and looking at 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; however, 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.