GithubHelp home page GithubHelp logo

zilchms / facterdb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from voxpupuli/facterdb

0.0 0.0 0.0 2.6 MB

A Database of OS facts provided by Facter

License: Apache License 2.0

Shell 18.64% Ruby 61.44% PowerShell 19.41% Batchfile 0.51%

facterdb's Introduction

facterdb

License Test Release RubyGem Version RubyGem Downloads Donated by Camptocamp

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

FacterDB

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')

Included Factsets

Starting with version 1.28.0 (May 2024), check RubyDoc for Factsets included in each released gem. Check the Voxpupuli website for Factsets included in the master branch.

Add new Operating System support

There is Vagrantfile to automagically populate facts for all supported operating systems by spawning a new VM and launches a provisioning scripts. Details of how to generate facts for each operating system are here.

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'

Debugging fact sets

By setting the environment variable FACTERDB_INJECT_SOURCE the following facts are injected into all fact sets:

_facterdb_path : The base name of the file used to load this fact set e.g. centos-5-i386.facts

_facterdb_filename : The full path of the file used to load this fact set e.g. /project/facter-db/centos-5-i386.facts

{
  "_facterdb_path": "centos-5-i386.facts",
  "_facterdb_filename": "/project/facter-db/centos-5-i386.facts",
  "aio_agent_version": "1.8.3",
  "architecture": "i386",
  "augeas": {
    "version": "1.4.0"
  },
  "augeasversion": "1.4.0",
  "bios_release_date": "07/30/2013",
  "bios_vendor": "Phoenix Technologies LTD",
  "bios_version": "6.00",
  "blockdevice_fd0_size": 4096,
  "blockdevice_hdc_size": 4294965248,
  "blockdevice_sda_model": "Virtual disk",
  ...

To set the environment variable use;

bash> FACTERDB_INJECT_SOURCE='true'

or on Windows

powershell> $ENV:FACTERDB_INJECT_SOURCE = 'true'

Contributing

Please submit issues at https://github.com/voxpupuli/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.

Transfer Notice

This plugin was originally authored by Camptocamp. The maintainer preferred that Puppet Community take ownership of the module for future improvement and maintenance. Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of Camptocamp.

Previously: https://github.com/camptocamp/facterdb

facterdb's People

Contributors

bastelfreak avatar rodjek avatar mcanevet avatar raphink avatar ekohl avatar smortex avatar hbrown-uiowa avatar yakatz avatar glennsarti avatar davidsandilands avatar davids avatar dependabot[bot] avatar adamcrews avatar genebean avatar logicminds avatar baurmatt avatar treydock avatar bodgit avatar ghoneycutt avatar zilchms avatar yachub avatar petems avatar themeier avatar tjm avatar traylenator avatar b4ldr avatar jhoblitt avatar kenyon avatar mmoll avatar blackknight36 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.