Skip to content

bastelfreak/facterdb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

facterdb

Build Status Code Climate Gem Version Gem Downloads Coverage Status

A Gem that contains a lot of facts for a lot of Operating Systems.

Usage

CLI

facterdb 'facterversion=/^2.4\./ and (operatingsystem=Debian and operatingsystemrelease>=7 or operatingsystem=RedHat and operatingsystemrelease=/^7/)'

Will return a JSON containing the facts for Debian 7, Debian 8 and RedHat 7 generated by Facter 2.4.

Ruby

require 'facterdb'
FacterDB::get_facts()

Returns an Array of Hash containing the whole facts database.

Filtering by Facter version and fact values

With an Array filter

require 'facterdb'

FacterDB.get_facts([{:osfamily => 'Debian'}])

With an Hash filter

require 'facterdb'

FacterDB.get_facts({:osfamily => 'Debian'})

With a String filter

require 'facterdb'

FacterDB::get_facts('osfamily=Debian')

Facter versions supported

  • 1.6
  • 1.7
  • 2.0
  • 2.1
  • 2.2
  • 2.3
  • 2.4
  • 3.0
  • 3.1
  • 3.3
  • 3.4
  • 3.5
  • 3.6
  • 3.7
  • 3.8

Operating Systems supported

  • AIX
  • ArchLinux
  • CentOS 5
  • CentOS 6
  • CentOS 7
  • Debian 6
  • Debian 7
  • Debian 8
  • Fedora 19
  • Fedora 22
  • Fedora 23
  • Fedora 24
  • FreeBSD 9
  • FreeBSD 10
  • Gentoo
  • OpenBSD 5.7
  • OpenBSD 5.8
  • OpenBSD 5.9
  • OpenBSD 6.0
  • OpenSuse 12
  • OpenSuse 13
  • Oracle 5
  • Oracle 6
  • Oracle 7
  • RedHat 5
  • RedHat 6
  • RedHat 7
  • Scientific 5
  • Scientific 6
  • Scientific 7
  • SLES 11
  • SLES 12
  • Solaris 11
  • OSX 10.10
  • Ubuntu 10.04
  • Ubuntu 12.04
  • Ubuntu 14.04
  • Ubuntu 14.10
  • Ubuntu 15.04
  • Ubuntu 15.10
  • Ubuntu 16.04
  • Windows 2012 r2
  • Windows 7

Add new Operating System support

There is Vagrantfile to automagically populate facts directory by spawning a new VM and launches a provisioning scripts.

$ cd facts
$ vagrant up --provision

Create i386 facts from x86_64's ones

for file in facts/*/*-x86_64.facts; do cat $file | sed -e 's/x86_64/i386/' -e 's/amd64/i386/' > $(echo $file | sed 's/x86_64/i386/'); done

Create RedHat, Scientific, OracleLinux facts from CentOS's ones

for file in facts/*/centos-*.facts; do cat $file | sed -e 's/CentOS/RedHat/' > $(echo $file | sed 's/centos/redhat/'); done
for file in facts/*/centos-*.facts; do cat $file | sed -e 's/CentOS/Scientific/' > $(echo $file | sed 's/centos/scientific/'); done
for file in facts/*/centos-*.facts; do cat $file | sed -e 's/CentOS/OracleLinux/' > $(echo $file | sed 's/centos/oraclelinux/'); done

Supplying custom external facts

The default facts are great for many things but there will be times when you need to have facterdb search custom fact sets that only make sense in your environment or might contain sensitive information.

This can be useful when combined with rspec_puppet_facts or the puppet-debugger which both use this gem.

To supply external facts to facterdb just set the FACTERDB_SEARCH_PATHS environment variable with one or more paths to your facts. Do this any time facterdb is used directly or indirectly.

When separating paths please use the default path separator character supported by your OS.

  • Unix/Linux/OSX = :
  • Windows = ;

Each fact set you create must meet the following requirements:

  1. A JSON serialized file containing a single Hash of all the facts.
  2. The facts file must end in .facts
  3. Must be placed inside some directory. You can organize this directory however you like.

Facterdb is smart enough the search your supplied directories for files ending with '.facts'. You can even supply multiple directories.

Example:

FACTERDB_SEARCH_PATHS="/var/opt/lib/custom_facts"

or

FACTERDB_SEARCH_PATHS="/var/opt/lib/custom_facts:/tmp/custom_facts:/home/user1/custom_facts"

We still highly encourage you to create pull requests with new fact sets over of using external facts.

You can create these files via many methods.

  • puppet facts | jq '.values' > /tmp/custom_facts/datacenter_a/2.4/os_x.facts # must have jq command
  • Via puppetdb queries
  • hand crafted

Additionally you can skip the default FacterDB facts completely by setting the environment variable FACTERDB_SKIP_DEFAULTDB. This will instruct facterdb to not look at its built-in facts which can be useful should you need to completely replace which facts are used.

Setting the variable FACTERDB_SKIP_DEFAULTDB to anything will disable the internal facts used by facterdb. You would most likely use this in combination with the FACTERDB_SEARCH_PATHS environment variable.

Example:

FACTERDB_SEARCH_PATHS="/var/opt/lib/custom_facts:/tmp/custom_facts:/home/user1/custom_facts"
FACTERDB_SKIP_DEFAULTDB='yes'

Contributing

Please submit issues at https://github.com/camptocamp/facterdb/issues or PRs in the same repository.

Release process

  • Update the version in lib/facterdb/version.rb
  • Run rake changelog
  • Commit and PR the results.

About

A Database of OS facts provided by Facter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 68.8%
  • PowerShell 17.3%
  • Shell 13.3%
  • Batchfile 0.6%