Roles operations

Command line interface

The pglift role command line entry point exposes commands to manage PostgreSQL roles of an instance.

$ pglift role --help
Usage: pglift role [OPTIONS] COMMAND [ARGS]...

  Manage roles.

  -i, --instance <version>/<name>
                                  Instance identifier; the <version>/ prefix
                                  may be omitted if there's only one instance
                                  matching <name>. Required if there is more
                                  than one instance on system.
  --schema                        Print the JSON schema of role model and
  --help                          Show this message and exit.

  alter       Alter a role in a PostgreSQL instance
  create      Create a role in a PostgreSQL instance
  drop        Drop a role
  get         Get the description of a role
  list        List roles in instance
  privileges  List privileges of a role.

Ansible module

The role module within dalibo.pglift collection is the main entry point for PostgreSQL roles management through Ansible.

Example task:

  - name: my role
      instance: myinstance
      name: dba
      pgpass: true
      login: true
      connection_limit: 10
      validity: '2025-01-01T00:00'
        - pg_read_all_stats
        - pg_signal_backend

It’s also possible to use the instance module within dalibo.pglift collection as the main entry point to manage your PostgreSQL role. Some examples about managing roles directly with the Ansible instance module are available under the dedicated documentation.