module-postgresql/lib/facter/postgres_default_version.rb
Adrien Thebo 04a7b06d15 Update postgres_default_version to 9.1 for debian 7.0
/etc/debian_version on Wheezy was updated to 7.0 with the release of the
base-files package on 2012-12-12, which means that wheezy could be
either 7.0 or wheezy depending on what version of base-files is
installed. To handle both cases we treat 'wheezy' and '7.*' as
synonymous.
2013-01-22 20:54:19 -08:00

63 lines
1.2 KiB
Ruby

def get_debianfamily_postgres_version
case Facter.value('operatingsystem')
when "Debian"
get_debian_postgres_version()
when "Ubuntu"
get_ubuntu_postgres_version()
else
nil
end
end
def get_debian_postgres_version
case Facter.value('operatingsystemrelease')
# TODO: add more debian versions or better logic here
when /^6\./
"8.4"
when /^wheezy/, /^7\./
"9.1"
else
nil
end
end
def get_ubuntu_postgres_version
case Facter.value('operatingsystemrelease')
# TODO: add more ubuntu versions or better logic here
when "12.04"
"9.1"
when "10.04"
"8.4"
else
nil
end
end
def get_redhatfamily_postgres_version
case Facter.value('operatingsystemrelease')
when /^6\./
"8.4"
when /^5\./
"8.1"
else
nil
end
end
Facter.add("postgres_default_version") do
setcode do
result =
case Facter.value('osfamily')
when 'RedHat'
get_redhatfamily_postgres_version()
when 'Debian'
get_debianfamily_postgres_version()
else
nil
end
if result == nil
result = "Unsupported OS! Please check `postgres_default_version` fact."
end
result
end
end