Forge Home

exportfact

Publish and share facts between nodes

11,150 downloads

10,927 latest version

1.9 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.1.1 (latest)
  • 0.1.0
released Jul 10th 2013

Start using this module

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

Add this module to your Puppetfile:

mod 'hastexo-exportfact', '0.1.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add hastexo-exportfact
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install hastexo-exportfact --version 0.1.1

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: facts, facter

Documentation

hastexo/exportfact — version 0.1.1 Jul 10th 2013

exportfact: Publish and share facts between nodes

This module enables nodes to publish information about themselves using custom facts, which are then exported to other nodes.

Example

Suppose you have a node, alice, that you configure as an HTTP proxy server. And you want all your other nodes to use that node's IP address as their HTTP proxy.

First, you could make sure that your proxy server sets an exported fact, let's call it http_proxy_host:

node alice {
  include exportfact

  exportfact::export { 'http_proxy_host':
    value => $hostname,
    category => "http_proxy"
  }
}

The category is a logical grouping of facts.

Then, say every other node should know about the facts in the http_proxy category:

include exportfact

exportfact::import { 'http_proxy': }

Once the configuration has been applied on both the exporting and the importing nodes, facter -p http_proxy on the importing node will produce the $hostname of the exporting node (in the example, alice).

Of course, you might also export other information about the service. $ipaddress or $fqdn come to mind, for example.

Background

On the exporting node, exportfact::export creates a file named <category>.txt in the facts.d directory (normally, /etc/facter/facts.d). Within this file, it uses Augeas to create name=value pairs. It is the Augeas resource, not the full contents of the file, that is exported.

On the importing node, in exportfact::import it's again Augeas that sets the exported value in the category.txt file, such that Facter can pick it up as a custom fact on its next run.

Note that exportfact::export exports a single fact, while exportfact::import imports all facts within a given category. This distinction is deliberate.

Prerequisites

As this module uses exported resources, it only works when Stored Configuration is enabled:

[master]
storeconfigs = true

See the Puppet (and PuppetDB) documentation for more information about Stored Configuration.