Search code examples
postgresqlversionsalt-project

Install specific version of postgres using saltstack


I'm wanting a really basic install of postgres, and the postgres-formula/postgres is just too crazy. I just want to install postgres version 9.5.1 on a single minion.

Here's something I've tried, that I know doesn't work.

/srv/salt/top.sls

base:
  '*':
    - postgresql

/srv/salt/postgresql/init.sls

postgresql:
  pkg.installed:
      - version: 9.5.1

According to the documentation here, this is the correct format. I thought maybe I should have the 9.5.3 in a different format, but I can't find where to figure that out.


Update 1

I'm using ubuntu 14.04 on the minion, and the master.

The output of apt-cache policy postgresql is

postgresql:
  Installed: (none)
  Candidate: 9.3+154ubuntu1
  Version table:
     9.3+154ubuntu1 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
     9.3+154 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

Solution

  • This should be done through salt using pkgrepo.managed. The solution is below.

    init.sls

     postgresql:
      pkgrepo.managed:
        - name: deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
        - dist: trusty-pgdg
        - file: /etc/apt/sources.list.d/psql.list
        - key_url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
        - require_in:
          - pkg: postgresql
      pkg.installed:
        - name: postgresql-9.5
        - refresh: True
      service:
        - running
    

    I got this answer through a combination of the saltstack irc, and the salt docs.