# Managing postgres functions/tirggers with ansible

**URL:** <https://forum.ansible.com/t/managing-postgres-functions-tirggers-with-ansible/38757>\
**Category:** Ansible Project\
**Created:** [April 17, 2024, 2:59pm UTC](https://forum.ansible.com/t/managing-postgres-functions-tirggers-with-ansible/38757 "2024-04-17T14:59:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [April 17, 2024, 2:59pm UTC](https://forum.ansible.com/t/managing-postgres-functions-tirggers-with-ansible/38757/1 "2024-04-17T14:59:49Z")

</div>

Hi,

I'm trying to manage a postgres database with ansible.  
Database OK, users OK, tables OK.  
But now I have a table which has a field that should auto update with  
NOW() upon changes. So far that requires SQL statements like this:

CREATE FUNCTION ...  
CREATE TRIGGER...

I looked at [https://docs.ansible.com/ansible/latest/collections/community/postgresql/index.html](https://docs.ansible.com/ansible/latest/collections/community/postgresql/index.html)  
but I don;t immediately see something that suits...  
Any suggestions?

thx!

Dick

---

<div class="post-metadata">

**Author:** ![rolandm](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/rolandm/32/755_2.png) [@rolandm](https://forum.ansible.com/u/rolandm)\
**Post date:** [April 17, 2024, 7:21pm UTC](https://forum.ansible.com/t/managing-postgres-functions-tirggers-with-ansible/38757/2 "2024-04-17T19:21:44Z")

</div>

Hello,

I think the postgresql ansible module is for administrating postgresql or enabling the execution of scripts or queries rather then providing a some layer around DDL or DML commands for PostgreSQL.

You should be able to use postgresql\_query\_module or postgresql\_script\_module for executing the SQL you have to provide.

BR,  
Roland
