i am trying to setup pgbackrest with ansible and i have stumbled upon GRANTing EXECUTE on the function pg_backup_start
i have the following ansible snippet:
- name: GRANT EXECUTE on function pg_start_backup
community.postgresql.postgresql_privs:
database: postgres
privs: EXECUTE
schema: pg_catalog
objs: "pg_start_backup(label text: fast boolean)"
type: function
roles: ${dockeruser}
login_user: ${db_admin_user}
login_password: ${db_admin_password}
login_host: localhost
which gives the following error. which indicates that the function doesnt exist
│ "invocation": {
│ "module_args": {
│ "ca_cert": null,
│ "connect_params": {},
│ "database": "postgres",
│ "fail_on_role": true,
│ "grant_option": null,
│ "login_host": "localhost",
│ "login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
│ "login_unix_socket": "",
│ "login_user": "postgres",
│ "objs": "pg_start_backup(label text: fast boolean)",
│ "password": "",
│ "port": 5432,
│ "privs": "EXECUTE",
│ "roles": "docker-service",
│ "schema": "pg_catalog",
│ "session_role": null,
│ "ssl_cert": null,
│ "ssl_key": null,
│ "ssl_mode": "prefer",
│ "state": "present",
│ "target_roles": null,
│ "trust_input": true,
│ "type": "function"
│ }
│ },
│ "msg": "Cannot execute SQL 'GRANT EXECUTE ON function \"pg_catalog\".\"pg_start_backup\"(label text, fast boolean) TO \"docker-service\";': function pg_catalog.pg_start_backup(text, boolean) does not exist\n"
│ }
but when i try with the following ansible:
- name: GRANT EXECUTE on function pg_start_backup
community.postgresql.postgresql_privs:
database: postgres
privs: EXECUTE
schema: pg_catalog
objs: "pg_start_backup"
type: function
roles: ${dockeruser}
login_user: ${db_admin_user}
login_password: ${db_admin_password}
login_host: localhost
i get the following error:
│ "changed": false,
│ "invocation": {
│ "module_args": {
│ "ca_cert": null,
│ "connect_params": {},
│ "database": "postgres",
│ "fail_on_role": true,
│ "grant_option": null,
│ "login_host": "localhost",
│ "login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
│ "login_unix_socket": "",
│ "login_user": "postgres",
│ "objs": "pg_start_backup",
│ "password": "",
│ "port": 5432,
│ "privs": "EXECUTE",
│ "roles": "docker-service",
│ "schema": "pg_catalog",
│ "session_role": null,
│ "ssl_cert": null,
│ "ssl_key": null,
│ "ssl_mode": "prefer",
│ "state": "present",
│ "target_roles": null,
│ "trust_input": true,
│ "type": "function"
│ }
│ },
│ "msg": "Illegal function / procedure signature: \"pg_start_backup\"."
│ }
i have search through internet and chatgpt for an example but my skills fails me ![]()
i tried to grant for a function that has no paramters pg_backend_pid
- name: GRANT EXECUTE on function pg_start_backup
community.postgresql.postgresql_privs:
database: postgres
privs: EXECUTE
schema: pg_catalog
objs: "pg_backend_pid()"
type: function
roles: ${dockeruser}
login_user: ${db_admin_user}
login_password: ${db_admin_password}
login_host: localhost
which succeeds