creating a postgres user - non default postgres port

47 views
Skip to first unread message

dulh...@mailbox.org

unread,
Sep 26, 2022, 6:10:22 AM9/26/22
to ansible...@googlegroups.com
I am trying to create a postgres user/role with community.postgresql.postgresql_user.
The instance I am trying to address runs on port 5436 so my TASK looks like

############################################################################
- name: create db admin user
community.postgresql.postgresql_user:
name: "{{ item }}"
become: true
port: "{{ pg_service_port.stdout }}"
loop:
- "{{ pg_service_admin }}"
############################################################################

the pg_service_port.stdout value is created earlier in my playbook and equals to 5436 in the example here

however creation of the postgres user throws this error at me:

ssh: connect to host vm-414001-0227.step.zrz.dvz.cn-mv.de port 5436

this looks as it the expected port is used to try connection to my remote host via ssh for that particular TASK, not logging in to postgresql.

the docs imply something else though

- port
Database port to connect to.
(Aliases: login_port)[Default: 5432]
type: int

so ... what is my misinterpretation here?

I can make it work with a shell command, so at least I can confirm the variables and basic logic works

############################################################################
- name: create db_admin user with shell
ansible.builtin.shell:
cmd: '/opt/db/postgres/postgresql-12.11-postgis-3.2.1-el8-ina1/bin/psql -p {{ pg_service_port.stdout }} -c "CREATE ROLE {{ pg_service_admin }};"'
become: true
############################################################################

Dick Visser

unread,
Sep 26, 2022, 6:51:03 AM9/26/22
to ansible...@googlegroups.com
This is correct, you supplied the port parameter at the task level itself, while you should provide it to the task. 

Indent one level more.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/143191617.565062.1664186997508%40office.mailbox.org.
--
Sent from Gmail Mobile
Reply all
Reply to author
Forward
0 new messages