Sha256: ab43924ebea436753cad8a985d922f1a10ed4b0ed8c7d256c9ddeb0bfac3a176

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

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')
    when "11.10", "12.04", "12.10", "13.04"
      "9.1"
    when "10.04", "10.10", "11.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 'Linux'
          get_redhatfamily_postgres_version()
        when 'Debian'
          get_debianfamily_postgres_version()
        else
          nil
      end

    # TODO: not sure if this is really a great idea, but elsewhere in the code
    # it is useful to be able to distinguish between the case where the fact
    # does not exist at all (e.g., if pluginsync is not enabled), and the case
    # where the fact is not known for the OS in question.
    if result == nil
      result = 'unknown'
    end
    result
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
freighthop-0.0.6 modules/postgresql/lib/facter/postgres_default_version.rb
freighthop-0.0.5 modules/postgresql/lib/facter/postgres_default_version.rb
freighthop-0.0.4 modules/postgresql/lib/facter/postgres_default_version.rb
freighthop-0.0.3 modules/postgresql/lib/facter/postgres_default_version.rb
freighthop-0.0.2 modules/postgresql/lib/facter/postgres_default_version.rb
freighthop-0.0.1 modules/postgresql/lib/facter/postgres_default_version.rb