Created
August 17, 2018 05:20
-
-
Save binford2k/3ddb6614665f63a97f7dba3f85f31814 to your computer and use it in GitHub Desktop.
/usr/local/bin/facter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'json' | |
ENV['facter_cache'] ||= `/opt/puppetlabs/bin/facter --show-legacy --no-external-facts --json` | |
cache = JSON.parse(ENV['facter_cache']) rescue {} | |
value = ARGV.first.split('.').reduce(cache) do |collector, key| | |
break unless collector.keys.include? key | |
collector[key] | |
end | |
value ||= `/opt/puppetlabs/bin/facter --show-legacy --puppet #{ARGV.first}` | |
print value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment