2012-12-07 19:40:18 +01:00
|
|
|
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
|
|
|
|
|
2012-06-08 22:37:21 +02:00
|
|
|
def get_debian_postgres_version
|
2012-12-07 19:40:18 +01:00
|
|
|
case Facter.value('operatingsystemrelease')
|
|
|
|
# TODO: add more debian versions or better logic here
|
|
|
|
when /^6\./
|
|
|
|
"8.4"
|
|
|
|
else
|
|
|
|
nil
|
2012-06-08 22:37:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-07 19:40:18 +01:00
|
|
|
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
|
2012-06-08 22:37:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Facter.add("postgres_default_version") do
|
|
|
|
setcode do
|
2012-12-07 19:40:18 +01:00
|
|
|
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."
|
2012-06-08 22:37:21 +02:00
|
|
|
end
|
2012-12-07 19:40:18 +01:00
|
|
|
result
|
2012-06-08 22:37:21 +02:00
|
|
|
end
|
2012-12-07 19:40:18 +01:00
|
|
|
end
|