Skip to content

Instantly share code, notes, and snippets.

@GeoffWilliams
Last active June 10, 2016 05:29
Show Gist options
  • Select an option

  • Save GeoffWilliams/bbaf5e5b0f20d968cc3c07124da649af to your computer and use it in GitHub Desktop.

Select an option

Save GeoffWilliams/bbaf5e5b0f20d968cc3c07124da649af to your computer and use it in GitHub Desktop.
Example of how to do a custom fact parsing output from a perl script that outputs YAML. This ruby file must be distributed via a module as a custom fact and should be saved in the modules lib/facter directory. The facter command can then be used to inspect the resulting structure, eg facter -p myfact.testdata.data1
require 'yaml'
Facter.add(:myfact) do
setcode do
YAML.load(Facter::Core::Execution.exec("/usr/local/bin/mycoolscript.pl"))
end
end
@GeoffWilliams
Copy link
Author

Use Facter::Core::Execution instead of %x{} to have more control over executions and errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment