Skip to content

Instantly share code, notes, and snippets.

@cardil
Last active February 23, 2018 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cardil/836aaf0642c167656a08daff44db051a to your computer and use it in GitHub Desktop.
Save cardil/836aaf0642c167656a08daff44db051a to your computer and use it in GitHub Desktop.
Fact.new(:databases) do
setcode do
output = Facter::Util::Resolution.exec('pgsql listdb')
if $?.success?
{
status: :ok,
list: output.split("\n")
}
else:
raise output
end
rescue e
{
status: e,
list: []
}
end
end
# databases.status: ok
# databases.list: ['acme', 'foo']
# databases.status: Brak polaczenia do bazy
# databases.list: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment