Forge Home

pkg_inventory

Export package inventory facts

8,729 downloads

8,124 latest version

4.3 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

  • 0.2.0 (latest)
  • 0.1.0
released May 26th 2016
This version is compatible with:
  • Puppet Enterprise >= 3.0.0 < 5.0.0
  • Puppet >= 3.0.0 < 5.0.0
  • ,

Start using this module

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

Add this module to your Puppetfile:

mod 'rmueller-pkg_inventory', '0.2.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add rmueller-pkg_inventory
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install rmueller-pkg_inventory --version 0.2.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
Tags: inventory

Documentation

rmueller/pkg_inventory — version 0.2.0 May 26th 2016

pkg_inventory

Table of Contents

  1. Description
  2. Usage
  3. Limitations

Description

This module is exporting a structured fact hash ("packages") which contains all installed (RPM-) packages and their versions (including release and architecture).
It includes packages which are installed as a dependency and not managed via Puppet directly. As packages can be installed multiple times with different versions (e.g. "kernel"), the output is always an array with all installed versions.

It is intended to be used together with PuppetDB to provide a fast and reliable way to query all packages and versions in your infrastructure.

Usage

You only need to install the module on your puppet server. With pluginsync enabled your nodes will automatically export the fact afterwards.
There is no Puppet class you need to include.
You can check if the facts are working correctly, e.g.:

# facter -p packages
{
  audit_libs => [
    "2.3.3-4.el7.x86_64"
  ],
  jansson => [
    "2.4-6.el7.x86_64"
  ],
  sed => [
    "4.2.2-5.el7.x86_64"
  ],
  kernel => [
    "3.10.0-123.el7.x86_64",
    "3.10.0-327.18.2.el7.x86_64"
  ],
  libdb => [
    "5.3.21-17.el7.x86_64"
  ],
  (...)
}

You can now query PuppetDB for these facts.
E.g. "What version of yum is currently deployed on my servers?"

$ curl -s -X GET 'http://localhost:8080/pdb/query/v4/fact-contents?pretty=true' --data-urlencode 'query=["~>", "path", [ "packages", "yum", ".*" ]]'
[ {
  "certname" : "puppet",
  "path" : [ "packages", "yum", 0 ],
  "name" : "packages",
  "value" : "3.4.3-118.el7.centos.noarch",
  "environment" : "production"
}, {
  "certname" : "node1",
  "path" : [ "packages", "yum", 0 ],
  "name" : "packages",
  "value" : "3.4.3-118.el7.centos.noarch",
  "environment" : "production"
} ]

Limitations

Installing this module will obviously export a large number of additional facts. Depending on how many packages your systems have installed and how many systems you are running this may increase the size of your PuppetDB instance by a lot.
Enable with caution.

Currently only Red Hat based systems are supported but it should be simple to adapt it to other operating systems as well.

As this is exporting a structured fact you need to set stringify_facts to false when using Puppet 3.x.
That is the default in Puppet 4.0.0 and greater.