Question

I'm using Salt Stack to manage my Linux servers. I have a command that creates my PostgreSQL database, but I need to run "CREATE EXTENSION postgis;" on my database.

I know I can do this with a shell script that calls psql from the command line, but is there a more sensible way to do this with Salt?

Here's my current DB config script:

pg-deps:
    pkg:
        - installed
        - names:
            - postgresql-9.3
            - postgis

dbuser:
    postgres_user:
        - present
        - name: foo
        - password: bar
        - runas: postgres

dbname:
    postgres_database:
        - present
        - encoding: UTF-8
        - runas: postgres
        - owner: foo
        - require:
            - postgres_user: dbuser
Was it helpful?

Solution

There isn't a function in the postgres state to execute "CREATE EXTENSION". That would be a very useful addition.

In the meantime, using a 'cmd.run' that runs after the rest of the install should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top