Forge Home

inventory

Provides a Puppet face for dumping an inventory of a node

52,116 downloads

40,439 latest version

4.1 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.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 0.4.0 (latest)
  • 0.3.0
  • 0.2.0
  • 0.1.1
  • 0.1.0
released Oct 3rd 2016

Start using this module

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

Add this module to your Puppetfile:

mod 'puppetlabs-inventory', '0.4.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add puppetlabs-inventory
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install puppetlabs-inventory --version 0.4.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

puppetlabs/inventory — version 0.4.0 Oct 3rd 2016

inventory provides a new Puppet command which outputs a data structure describing properties of the system on which it's run.

Puppet Forge Build Status

Here's a quick example:

$ puppet inventory | head -n 20
{
  "schema_version": 1,
  "created": "2016-07-14T07:42:01Z",
  "resources": [
    {
      "title": "root",
      "resource": "group",
      "gid": 0
    },
    {
      "title": "bin",
      "resource": "group",
      "gid": 1
    },
    {
      "title": "daemon",
      "resource": "group",
      "gid": 2
    },
    {

Specifically inventory outputs information on:

  • Users
  • Groups
  • Packages
  • Services
  • Facts

All of this information is already available via the RAL and puppet resource or via facter. inventory simply offers a higher-level interface, a single command that outputs everything in a simplified data format.

Installation

inventory is packaged as a Puppet Module, and can be installed from the Forge like so:

puppet module install puppetlabs-inventory

You can also include in your Puppetfile if using r10k or librarian-puppet:

mod 'puppetlabs/inventory'

Demonstration

A simple way of demonstrating the module is to use Docker. Docker is not required, it just makes for nice single line examples. The following should be run from a checkout of this repository.

Output inventory information for the puppet/puppet-agent-alpine image from Hub:

docker run --rm -it -v $(pwd):/src:ro -e RUBYLIB=/src/lib puppet/puppet-agent-alpine inventory

Output the same information but instead of formatted JSON render the output as YAML:

docker run --rm -it -v $(pwd):/src:ro -e RUBYLIB=/src/lib puppet/puppet-agent-alpine inventory --render-as yaml

Only generate the resources portion of the output:

docker run --rm -it -v $(pwd):/src:ro -e RUBYLIB=/src/lib puppet/puppet-agent-alpine inventory resources

Only generate the facts portion of the output:

docker run --rm -it -v $(pwd):/src:ro -e RUBYLIB=/src/lib puppet/puppet-agent-alpine inventory facts

If you're doing something specific to Puppet you can also output the full Puppet Catalog. This is also an easy way of seeing how Puppet works under the hood.

docker run --rm -it -v $(pwd):/src:ro -e RUBYLIB=/src/lib puppet/puppet-agent-alpine inventory catalog

The above examples all use images which already have Puppet installed on them. This example runs an inventory of the vanilla centos image, which does not have Puppet installed. It does that by mounting Puppet from another container as described in the Puppet-in-Docker examples:

docker run --name puppet-agent -v /opt/puppetlabs puppet/puppet-agent-ubuntu --version
docker run --rm -it --volumes-from=puppet-agent -v $(pwd):/src:ro -e RUBYLIB=/src/lib centos /opt/puppetlabs/bin/puppet inventory all

Puppet inventory is also available as a Docker Image from Hub. So the following is a clearer way of doing the above

docker run --name puppet-inventory puppet/puppet-inventory
docker run --rm -it --volumes-from=puppet-inventory centos /opt/puppetlabs/bin/puppet inventory

Status and Schema Version

This is an early prototype at the moment and based on experience with writing clients for the generated format the structure of the data produced may change a lot between now and a 1.0 release of the module. I will increment the schema_version key in the output if/when I make changes but until the module hits a 1.0 release don't expect any backwards compatibility guarantees.

Maintainers

This repository is maintained by: Gareth Rushgrove gareth@puppet.com.