Documentation
PLEASE NOTE: This document applies to latest version and not to the latest stable release v2.21
Documentation for other releases can be found by using the version selector in the top right of any doc page.postgresql_user
Add or remove PostgreSQL users (roles).
Attributes
check_mode:
support: full
Parameters
| Parameter | Required | Type | Values | Description |
|---|---|---|---|---|
| name | true | string | Name of the user (role) to add or remove. | |
| state | string | present absent |
The user state. | |
| password | string | Password for the user. | ||
| encrypted | boolean | Whether the password is already encrypted. | ||
| role_attr_flags | string | Role attributes flags. | ||
| login_host | string | Host running the database. | ||
| login_user | string | The username to authenticate with. | ||
| login_password | string | The password to authenticate with. | ||
| port | integer | Database port to connect to. | ||
| login_unix_socket | string | Path to a Unix domain socket for local connections. | ||
| ssl_mode | string | Disable SSL certificate verification. |
Examples
- name: Create a new user with password
postgresql_user:
name: app_user
password: secret
state: present
- name: Create a user with specific role attributes
postgresql_user:
name: app_admin
password: admin_password
role_attr_flags: CREATEDB,NOSUPERUSER
state: present
- name: Create a superuser
postgresql_user:
name: admin_user
password: admin_secret
role_attr_flags: SUPERUSER
state: present
- name: Remove a user
postgresql_user:
name: old_user
state: absent
- name: Connect to remote database and create user
postgresql_user:
name: remote_user
password: remote_pass
login_host: db.example.com
login_user: admin
login_password: secret
port: 5432
state: present