6034e122de
This is a first working version of postgresql::server. It includes a very simple test manifest, which has been tried out on CentOS6 and Ubuntu 10.04; initial tests were successful both from a clean state and for subsequent runs. Includes a new fact called 'postgres_default_version', which detects what the default version of postgres is for a given OS. This is needed because some of the commands and directory names include this version string. Current implementation *only* supports managing the system default version; in the future it would be nice to allow the user to explicitly specify a postgres version, but that isn't yet supported. The "postgresql::server" class includes a call to postgres's initdb command on redhat systems, because they don't do this automatically when the package is installed.
30 lines
No EOL
691 B
Ruby
30 lines
No EOL
691 B
Ruby
def get_debian_postgres_version
|
|
depends = Facter::Util::Resolution.exec('apt-cache show postgresql |grep "^Depends" |head -n 1')
|
|
if match = /^Depends: postgresql-(.*)$/.match(depends)
|
|
match[1]
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
def get_redhat_postgres_version
|
|
version = Facter::Util::Resolution.exec('yum info postgresql-server |grep "^Version"')
|
|
if match = /^Version\s*:\s*(\d+\.\d+).*$/.match(version)
|
|
match[1]
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
Facter.add("postgres_default_version") do
|
|
setcode do
|
|
case Facter.value('osfamily')
|
|
when 'RedHat'
|
|
get_redhat_postgres_version()
|
|
when 'Debian'
|
|
get_debian_postgres_version()
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
end |