GithubHelp home page GithubHelp logo

voxpupuli / facterdb Goto Github PK

View Code? Open in Web Editor NEW
42.0 39.0 74.0 4.26 MB

A Database of OS facts provided by Facter

Home Page: http://voxpupuli.org/facterdb/

License: Apache License 2.0

Ruby 63.17% Shell 17.75% PowerShell 18.59% Batchfile 0.49%
hacktoberfest ruby

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

With facterdb 2 legacy facts are deprecated and will be removed in facterdb 3

Some facts were declared legacy a long time ago: Core facts documentation With Puppet 8 they are disabled by default. With the release of facterdb 3 we will also remove the legacy facts from our factsets.

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

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

facterdb's Issues

use โ€”show-legacy flag with facter 3+ facts

Facter 3 by default does not show many of the facts that we are used to in pre facter 3 facts. In order to have the "legacy facts" in the facts hash please use --show-legacy when producing the fact hash.

facterdb conflict

This was previously fixed 21 days ago via #156 . Can we get a new release of facterdb

Unable to activate facterdb-1.4.0, because facter-4.0.14 conflicts with facter (< 4.0.0) (Gem::ConflictError)

Add support for Facter 2.5

Looks like Facter 2.5 came out on the 14 July, so appears to create an unfortunate situation where rspec-puppet-facts doesn't test anything if bundler happens to get the facter 2.5.0 gem, as it can't find any OSes in the FacterDB.

Remove duplicate default factset files

There are many duplicate files in the default fact set which serve no purpose. These should be removed and tests added to ensure they can not be re-added again.

AIX Fact dumps?

AIX is only supported on Puppet Enterprise, and is borderline impossible to virtualize.

I have access to some AIX machines I could add this from, would that be something you'd accept a PR for? I've been developing some code against AIX and having some examples of facts in AIX would've been super helpful.

create new release

Can we create a new release with the changes that were recently merged. I have some pending downstream gems that are going to require the next release.

Release new version

In git master there's support for OpenBSD 6 and SLES 12. It'd be useful if this was released into a gem.

Facts for archlinux release 4 are missing.

As stated in title.
Output for rake spec:
No facts were found in the FacterDB for: [{:facterversion=>"/^2.4/", :operatingsystem=>"Archlinux", :operatingsystemrelease=>"/^4/", :hardwaremodel=>"x86_64"}]

allow loading of external fact hashes

I would like the ability to load external fact hashes that are not part of the database. I think this would be useful for two reasons.

  1. allow user to utilize their own custom fact values that are not in the database for spec testing
  2. allow user to utilize their own custom facts for hiera lookup validations.

nwops/puppet-debugger#38

undefined method `downcase' for 0.8.1

Heyho,

after the new release 0.8.1 our rspec are broken due to undefined method downcase'`. They have been working with 0.8.0.

An error occurred while loading ./spec/classes/failures_spec.rb.
Failure/Error:
  on_unsupported_os.each do |os, os_facts|
    context "with unsupported #{os}" do
      let(:facts) do
        os_facts.merge(
          'sys11_ipaddress_private' => sys11_ipaddress_private,
          'memory' => {
            'system' => {
              'total_bytes' => memory_total_bytes,
            },
          },

NoMethodError:
  undefined method `downcase' for nil:NilClass
# /Users/mfroehner/.rvm/gems/ruby-2.5.5/gems/rspec-puppet-facts-unsupported-0.1.1/lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb:268:in `describe_os'
# /Users/mfroehner/.rvm/gems/ruby-2.5.5/gems/rspec-puppet-facts-unsupported-0.1.1/lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb:251:in `block in postprocess_facts'
# /Users/mfroehner/.rvm/gems/ruby-2.5.5/gems/rspec-puppet-facts-unsupported-0.1.1/lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb:250:in `map'
# /Users/mfroehner/.rvm/gems/ruby-2.5.5/gems/rspec-puppet-facts-unsupported-0.1.1/lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb:250:in `postprocess_facts'
# /Users/mfroehner/.rvm/gems/ruby-2.5.5/gems/rspec-puppet-facts-unsupported-0.1.1/lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb:232:in `facts'
# /Users/mfroehner/.rvm/gems/ruby-2.5.5/gems/rspec-puppet-facts-unsupported-0.1.1/lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb:27:in `on_unsupported_os'
# ./spec/classes/failures_spec.rb:101:in `block in <top (required)>'
# ./spec/classes/failures_spec.rb:6:in `<top (required)>'

Kind Regards,
Mike

Fact package_provider is missing

The package_provider fact is missing, probably because Facter only outputs it if called with --puppet? I assume FacterDB is mostly in the used in the context of Puppet spec testing, so I think supporting Puppet-specific facts makes sense

# facter --puppet package_provider
apt

Add facts for Amazon Linux

I generated the facts in #56 from a newly-provisioned Amazon Linux instance (AMI amzn-ami-hvm-2017.03.1.20170617-x86_64-gp2 ami-b2d056d3)

Wrong facts for Windows 2016(?)

Looks like major release for Windows 2016 is same as Windows 10, it leads to two results when should be only one.

Checked for version:
facterdb: 0.3.12
ruby: 2.2.5p319

require 'facterdb'

search = {
  "facterversion" => "/^3.3\./",
  "os.architecture" => 'x64',
  "os.release.major" => '10.0.14393',
  "os.name" => 'windows'
}

puts(search)
FacterDB.get_facts(search).each do |facts|
  puts(facts[:os])
end

search = {
  "facterversion" => "/^2.5\./",
  "architecture" => 'x64',
  "operatingsystem" => 'windows',
  "operatingsystemmajrelease" => '10'
  }

puts(search)
FacterDB.get_facts(search).each do |facts|
  puts(facts[:os])
end

---------------------------------------------

{"facterversion"=>"/^3.3./", "os.architecture"=>"x64", "os.release.major"=>"10.0.14393", "os.name"=>"windows"}        
{"architecture"=>"x64", "family"=>"windows", "hardware"=>"x86_64", "name"=>"windows", "release"=>{"full"=>"10.0.14393", "major"=>"10.0.14393"}, "windows"=>{"system32"=>"C:\\Windows\\system32"}}
{"architecture"=>"x64", "family"=>"windows", "hardware"=>"x86_64", "name"=>"windows", "release"=>{"full"=>"10.0.14393", "major"=>"10.0.14393"}, "windows"=>{"system32"=>"C:\\Windows\\system32"}}

{"facterversion"=>"/^2.5./", "architecture"=>"x64", "operatingsystem"=>"windows", "operatingsystemmajrelease"=>"10"}  
{"name"=>"windows", "family"=>"windows", "release"=>{"major"=>"10", "minor"=>"0", "full"=>"10.0.14393"}}              
{"name"=>"windows", "family"=>"windows", "release"=>{"major"=>"10", "full"=>"10"}}

Add facter 2.5 Gentoo facts

The latest facts for Gentoo in facterdb are those of Facter 2.4. As the default Facter version for all rspec Tests is currently 2.5, we desperately need updated facts for it.

I hope to provide a PR soon.

Consider adding the os::distro fact

Consider adding the os::distro fact. I run into puppet manifests that use codename to select templates, for example.

If you are interested I'll do this and submit a PR

Add support for facter 2.5

With recent release of faster 2.5.0, many test fail witch

No facts were found in the FacterDB for: [{:facterversion=>"/\\A2\\.5\\./", :operatingsystem=>"Debian", :operatingsystemrelease=>"/^8/", :hardwaremodel=>"x86_64"}]

We are using facterdb 0.3.11

drop support for 1.8.7 and then remove json dependency

1.8.7 is no longer supported. Additionally, ruby 1.9.3 comes with json in the core codebase so there is no need to list json as a dependency.

This is causing things like:

[puppet@puppetdev module]$ prepl
WARN: Unresolved specs during Gem::Specification.reset:
      json (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.

Archlinux legacy facts missing in 3.x fact sets.

eg There is no operatingsystem fact. This makes them unusable with rspec-puppet-facts.
The get_facts.sh script appears correct (it uses facter --show-legacy), so I don't know why they are missing.

Support for more suse versions

Please consider adding support for more suse versions. I'm especially interested in SLE[SD] 12 and SLED 11 but SLE[SD] 10 would be nice as well.

Add '::sytemd' fact?

I'm trying to use the '::systemd' fact exposed by 'camptocamp-systemd', however it's not included in FacterDB.

Would it be possible to include the '::systemd' fact in the FacterDB data?

New release

The Puppet Development Kit includes pinned gems and that includes facterdb 0.6.0. That is unfortunately a bit behind the times and leads to things like RHEL 6 and 7 not including the networking facts hash. It would be nice to see a newer version they could include in the next PDK release.

Release new version

If we could get a gem release with the 3.6 facts that would be appreciated ๐Ÿ™‡โ€โ™‚๏ธ

Similar tool created

Not sure why github created a duplicate of this tool, when this one could have been augmented. But check out the differences. https://github.com/github/octofacts

I think the only thing needed to have this work for more organizations is to allow them to extend fact hashes by providing an external directory. And some scripts to gather their own facts from puppetdb or similar methods.

Then add support for loading external directories which is similar to #27

IP address facts have disappeared

It looks like #124/#125 has lost the $::ipaddress fact (along with maybe some other network interface-related facts). It almost looks like the facts have been regenerated on a machine with no network interfaces present.

Raspbian support

I manage a fleet of over 300 Raspberry Pis using Puppet so I will be looking to submit a pull request in the near-future to add Raspbian support for versions 9 and 10.

Error `One or more the json documents could not be parsed. Run jgrep -v for to display documents`

Hi people,

At Vox Pupuli we recently got a PR to add Windows support. That PR also added several windows operating systems to the metadata.json:

diff --git a/metadata.json b/metadata.json
index e5ccd8c..e9502ad 100644
--- a/metadata.json
+++ b/metadata.json
@@ -151,6 +151,15 @@
         "9",
         "10"
       ]
+    },
+    {
+      "operatingsystem": "windows",
+      "operatingsystemrelease": [
+        "2008R2",
+        "2012",
+        "2012R2",
+        "2016"
+      ]
     }
   ]
 }

Since that we also see the following messages in travis runs:

One or more the json documents could not be parsed. Run jgrep -v for to display documents

My wild guess is that some of those facts are broken? However I tested them with jq and they all seem to contain valid JSON.

Overriding BSD architecture or missing OS entirely

If an operating system version is specified, on_supported_os will force hardwaremodel to amd64:
https://github.com/mcanevet/rspec-puppet-facts/blob/e02496555b0a79c0c0434ed99557b7097c5771b4/lib/rspec-puppet-facts.rb#L58-L59

But, if a version isn't specified, it won't make this change:
https://github.com/mcanevet/rspec-puppet-facts/blob/e02496555b0a79c0c0434ed99557b7097c5771b4/lib/rspec-puppet-facts.rb#L89-L94

Is this by design? Is there a good workaround?

Besides that, if an entire operating system disappears from the tests, there is no warning because https://github.com/mcanevet/rspec-puppet-facts/blob/e02496555b0a79c0c0434ed99557b7097c5771b4/lib/rspec-puppet-facts.rb#L113 just moves on to the next item. Shouldn't there be some kind of error (just like if the overall factor version is wrong)?

FreeBSD Support

Hello,

Do you still support FreeBSD. I am getting the following error

No facts were found in the FacterDB for: [{:facterversion=>"/\\A2\\.5\\./", :operatingsystem=>"FreeBSD", :operatingsystemrelease=>"/^10/", :hardwaremodel=>"amd64"}]
No facts were found in the FacterDB for: [{:facterversion=>"/\\A2\\.5\\./", :operatingsystem=>"FreeBSD", :operatingsystemrelease=>"/^10/", :hardwaremodel=>"amd64"}]
No examples found.

I am running the following versions

  • facter (2.5.1)
  • facterdb (0.3.12)

Im not too familure with the code of this project however a naive search shows that freebsd facts only exist upto version 2.4. so for now i have added facter < 2.5 to my gemspec as per this comment #44 (comment)

Thanks

Updated OpenBSD Facts

Currently, the newer facter versions are missing for OpenBSD. We should update the data for OpenBSD to address this.

3.11 facts for Debian Stretch and Ubuntu 18.04 are missing distro information

The 3.11 facts for Debian Stretch are missing distro information, this breaks it working with rspec-puppet-facts for example. All other 3.11 facts do seem to include the missing facts.

The facts are present in the 3.10 version: https://github.com/camptocamp/facterdb/blob/master/facts/3.10/debian-9-x86_64.facts

  "lsbdistcodename": "stretch",
  "lsbdistdescription": "Debian GNU/Linux 9.4 (stretch)",
  "lsbdistid": "Debian",
  "lsbdistrelease": "9.4",
  "lsbmajdistrelease": "9",
  "lsbminordistrelease": "4",

But these facts are missing in the 3.11 version: https://github.com/camptocamp/facterdb/blob/master/facts/3.11/debian-9-x86_64.facts
The same goes for Ubuntu 18.04.

The error you get with rspec-puppet-facts (and the query it uses):

No facts were found in the FacterDB for: [{:facterversion=>"/\\A3\\.11\\./", :operatingsystem=>"Debian", :operatingsystemrelease=>"/^9/", :hardwaremodel=>"x86_64"}, {:facterversion=>"/\\A3\\.11\\./", :operatingsystem=>"Ubuntu", :operatingsystemrelease=>"/^18.04/", :hardwaremodel=>"x86_64"}]

Is this intentional or a bug/something that went wrong?

solaris 10 facts are not found

The solaris 10 fact file is named solaris-10-i386.facts instead of solaris-10-i86pc.facts which is what facterdb is looking for.

I have renamed the fact file and sent a PR. In the same PR I have included factsets for Solaris 10 on facter 2.5 and facter 3.11. The one i sent last year that got merged in was for 3.9.

centos-7-x86 facts in 0.2.2 changed to AIO

There seems to be a difference in the facts/2.4/centos-7-x86_64.facts file between facterdb 0.2.1 and the latest 0.2.2 and 0.3.0 releases. The facts appear to have been regenerated using an AIO installation, which is causing us some failures in theforeman/foreman_proxy.

The GitHub repo though doesn't show these changes, so I wonder if there are local modifications that made it into the published gem? I'm unsure if it's an intentional change (I hope not).

https://gist.github.com/f9a45c848f87c8f4bb8e is a diff of the centos-7-x86.facts file between 0.2.1 and 0.3.0. Note that rubysitedir changes to /opt/puppetlabs while in https://github.com/camptocamp/facterdb/blob/0.3.0/facts/2.4/centos-7-x86_64.facts#L79 it's still /usr/local.

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.