Created
November 18, 2015 01:48
-
-
Save gutocarvalho/d60987f4cee423d017c4 to your computer and use it in GitHub Desktop.
This file contains 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
Facter.add(:postgresql) do | |
setcode do | |
confine :kernel => 'Linux' | |
postgresql = {} | |
distid = Facter.value(:osfamily) | |
case distid | |
when /RedHat|Suse/ | |
postgresql_check = Facter::Core::Execution.exec('which postmaster') | |
when "Debian" | |
postgresql_check = Facter::Core::Execution.exec('dpkg --list|awk \'{ print $1, $2 }\'|grep ^"ii postgresql"$') | |
end | |
if postgresql_check == "" | |
postgresql_installed = false | |
else | |
postgresql_installed = true | |
end | |
if postgresql_installed | |
distid = Facter.value(:osfamily) | |
case distid | |
when /RedHat|Suse/ | |
postgresql_version = Facter::Core::Execution.exec('rpm -q --queryformat "%{VERSION}" postgresql-server') | |
when "Debian" | |
postgresql_version = Facter::Core::Execution.exec('dpkg-query -W -f=\'${Version}\' postgresql') | |
else | |
postgresql_version = 'Unknown' | |
end | |
end | |
postgresql[:installed] = postgresql_installed | |
postgresql[:version] = postgresql_version | |
postgresql | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment