Created
December 6, 2018 15:57
-
-
Save fvoges/3093aa8c61dc1954d3ddce1384b4d76d to your computer and use it in GitHub Desktop.
Simple and structured custom fact examples
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
| # This custom fact is confined to RedHat and derivatives and | |
| # returns a simple fact (string) | |
| Facter.add('centrify') do | |
| confine Facter.value(:os)['family'] => 'RedHat' | |
| setcode do | |
| query = Facter::Core::Execution.execute('rpm -q --qf %{VERSION} CentrifyDC') | |
| if query =~ /\d+\.\d+/ | |
| query | |
| else | |
| '' | |
| end | |
| end | |
| end |
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
| # This custom fact is confined to RedHat and derivatives and | |
| # returns a structured fact (hash) | |
| Facter.add('centrify') do | |
| confine Facter.value(:os)['family'] => 'RedHat' | |
| setcode do | |
| query = Facter::Core::Execution.execute('rpm -q --qf %{VERSION} CentrifyDC') | |
| if query =~ /\d+\.\d+/ | |
| { | |
| "installed" => true, | |
| "version" => query | |
| } | |
| else | |
| { | |
| "installed" => false | |
| } | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment