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' -> db user
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 |
---|---|
note: | This module uses MD5 hashing which may not be compliant with certain security audits. |
List available postgresql extensions
CLI Example:
salt '*' postgres.available_extensions
Install a postgresql extension
CLI Example:
salt '*' postgres.create_extension 'adminpack'
Get lifecycle informations about an extension
CLI Example:
salt '*' postgres.create_metadata adminpack
Change tablespace or/and owner of database.
CLI Example:
salt '*' postgres.db_alter dbname owner=otheruser
Adds a databases to the Postgres server.
CLI Example:
salt '*' postgres.db_create 'dbname'
salt '*' postgres.db_create 'dbname' template=template_postgis
Checks if a database exists on the Postgres server.
CLI Example:
salt '*' postgres.db_exists 'dbname'
Return dictionary with information about databases of a Postgres server.
CLI Example:
salt '*' postgres.db_list
Removes a databases from the Postgres server.
CLI Example:
salt '*' postgres.db_remove 'dbname'
Drop an installed postgresql extension
CLI Example:
salt '*' postgres.drop_extension 'adminpack'
Get info about an available postgresql extension
CLI Example:
salt '*' postgres.get_available_extension plpgsql
Get info about an installed postgresql extension
CLI Example:
salt '*' postgres.get_installed_extension plpgsql
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'
Removes a group from the Postgres server.
CLI Example:
salt '*' postgres.group_remove 'groupname'
Updated a postgres group
CLI Examples:
salt '*' postgres.group_update 'username' user='user' \
host='hostname' port='port' password='password' \
rolepassword='rolepassword'
List installed postgresql extensions
CLI Example:
salt '*' postgres.installed_extensions
Test if a specific extension is installed
CLI Example:
salt '*' postgres.is_installed_extension
Test if a specific extension is installed
CLI Example:
salt '*' postgres.is_installed_extension
Set the owner of all schemas, functions, tables, views and sequences to the given username.
CLI Example:
salt '*' postgres.owner_to 'dbname' 'username'
Run an SQL-Query and return the results as a list. This command only supports SELECT statements. This limitation can be worked around with a query like this:
WITH updated AS (UPDATE pg_authid SET rolconnlimit = 2000 WHERE rolname = 'rolename' RETURNING rolconnlimit) SELECT * FROM updated;
CLI Example:
salt '*' postgres.psql_query 'select * from pg_stat_activity'
Return a dict with information about users of a Postgres server.
Set return_password to True to get password hash in the result.
CLI Example:
salt '*' postgres.role_get postgres
Creates a Postgres user.
CLI Examples:
salt '*' postgres.user_create 'username' user='user' \
host='hostname' port='port' password='password' \
rolepassword='rolepassword'
Checks if a user exists on the Postgres server.
CLI Example:
salt '*' postgres.user_exists 'username'
Return a dict with information about users of a Postgres server.
Set return_password to True to get password hash in the result.
CLI Example:
salt '*' postgres.user_list
Removes a user from the Postgres server.
CLI Example:
salt '*' postgres.user_remove 'username'
Updates a Postgres user.
CLI Examples:
salt '*' postgres.user_update 'username' user='user' \
host='hostname' port='port' password='password' \
rolepassword='rolepassword'
Return the version of a Postgres server.
CLI Example:
salt '*' postgres.version
Docs for previous releases are available on salt.rtfd.org.
Latest Salt release: 2014.7.2
22.16.147. salt.modules.postfix
22.16.149. salt.modules.poudriere
Upcoming SaltStack events, webinars and local meet ups and user groups.