# salt.modules.postgres

Module to provide Postgres compatibility to salt.

configuration: | In order to connect to Postgres, certain configuration is required in /etc/salt/minion on the relevant minions. Some sample configs might look like:
    postgres.host: 'localhost'
    postgres.port: '5432'
    postgres.user: 'postgres'
    postgres.pass: ''
    postgres.maintenance_db: 'postgres'
The default for the maintenance_db is 'postgres' and in most cases it can be left at the default setting. This data can also be passed into pillar. Options passed into opts will overwrite options passed into pillar

`salt.modules.postgres.` `db_alter`(name, user=None, host=None, port=None, maintenance_db=None, password=None, tablespace=None, owner=None, runas=None)

  Change tablesbase or/and owner of databse.

  CLI Example:

      salt '*' postgres.db_alter dbname owner=otheruser

`salt.modules.postgres.` `db_create`(name, user=None, host=None, port=None, maintenance_db=None, password=None, tablespace=None, encoding=None, lc_collate=None, lc_ctype=None, owner=None, template=None, runas=None)

  Adds a databases to the Postgres server.

  CLI Example:

      salt '*' postgres.db_create 'dbname'

      salt '*' postgres.db_create 'dbname' template=template_postgis

`salt.modules.postgres.` `db_exists`(name, user=None, host=None, port=None, maintenance_db=None, password=None, runas=None)

  Checks if a database exists on the Postgres server.

  CLI Example:

      salt '*' postgres.db_exists 'dbname'

`salt.modules.postgres.` `db_list`(user=None, host=None, port=None, maintenance_db=None, password=None, runas=None)

  Return dictionary with information about databases of a Postgres server.

  CLI Example:

      salt '*' postgres.db_list

`salt.modules.postgres.` `db_remove`(name, user=None, host=None, port=None, maintenance_db=None, password=None, runas=None)

  Removes a databases from the Postgres server.

  CLI Example:

      salt '*' postgres.db_remove 'dbname'

`salt.modules.postgres.` `group_create`(groupname, user=None, host=None, port=None, maintenance_db=None, password=None, createdb=False, createuser=False, encrypted=False, superuser=False, replication=False, rolepassword=None, groups=None, runas=None)

  Creates a Postgres group. A group is postgres is similar to a user, but cannot login.

  CLI Example:

      salt '*' postgres.group_create 'groupname' user='user' \
              host='hostname' port='port' password='password' \
              rolepassword='rolepassword'

`salt.modules.postgres.` `group_remove`(groupname, user=None, host=None, port=None, maintenance_db=None, password=None, runas=None)

  Removes a group from the Postgres server.

  CLI Example:

      salt '*' postgres.group_remove 'groupname'

`salt.modules.postgres.` `group_update`(groupname, user=None, host=None, port=None, maintenance_db=None, password=None, createdb=False, createuser=False, encrypted=False, replication=False, rolepassword=None, groups=None, runas=None)

  Updated a postgres group

  CLI Examples:

      salt '*' postgres.group_update 'username' user='user' \
              host='hostname' port='port' password='password' \
              rolepassword='rolepassword'

`salt.modules.postgres.` `owner_to`(dbname, ownername, user=None, host=None, port=None, password=None, runas=None)

  Set the owner of all schemas, functions, tables, views and sequences to the given username.

  CLI Example:

      salt '*' postgres.owner_to 'dbname' 'username'

`salt.modules.postgres.` `psql_query`(query, user=None, host=None, port=None, maintenance_db=None, password=None, runas=None)

  Run an SQL-Query and return the results as a list. This command only supports SELECT statements.

  CLI Example:

      salt '*' postgres.psql_query 'select * from pg_stat_activity'

`salt.modules.postgres.` `user_create`(username, user=None, host=None, port=None, maintenance_db=None, password=None, createdb=False, createuser=False, encrypted=False, superuser=False, replication=False, rolepassword=None, groups=None, runas=None)

  Creates a Postgres user.

  CLI Examples:

      salt '*' postgres.user_create 'username' user='user' \
              host='hostname' port='port' password='password' \
              rolepassword='rolepassword'

`salt.modules.postgres.` `user_exists`(name, user=None, host=None, port=None, maintenance_db=None, password=None, runas=None)

  Checks if a user exists on the Postgres server.

  CLI Example:

      salt '*' postgres.user_exists 'username'

`salt.modules.postgres.` `user_list`(user=None, host=None, port=None, maintenance_db=None, password=None, runas=None)

  Return a dict with information about users of a Postgres server.

  CLI Example:

      salt '*' postgres.user_list

`salt.modules.postgres.` `user_remove`(username, user=None, host=None, port=None, maintenance_db=None, password=None, runas=None)

  Removes a user from the Postgres server.

  CLI Example:

      salt '*' postgres.user_remove 'username'

`salt.modules.postgres.` `user_update`(username, user=None, host=None, port=None, maintenance_db=None, password=None, createdb=False, createuser=False, encrypted=False, replication=False, rolepassword=None, groups=None, runas=None)

  Creates a Postgres user.

  CLI Examples:

      salt '*' postgres.user_create 'username' user='user' \
              host='hostname' port='port' password='password' \
              rolepassword='rolepassword'

`salt.modules.postgres.` `version`(user=None, host=None, port=None, maintenance_db=None, password=None, runas=None)

  Return the version of a Postgres server.

  CLI Example:

      salt '*' postgres.version

Current Salt release: 0.17.1

#### Previous topic

salt.modules.portage_config

#### Next topic

salt.modules.poudriere

### Quick search

Enter search terms or a module, class or function name.

### Upcoming SaltStack Events

My conferences on Lanyrd