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. On Mon, 26 Sep 2022 at 12:10, dulhaver via Ansible Project < ansible-project@googlegroups.com> wrote: > 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 > > ############################################################################ > > -- > 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-project+unsubscr...@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 -- 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-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAF8BbLb_kdHYqe64WB3KWBZ1Bv-udY1mMkqkn9br-a9JkOZ63A%40mail.gmail.com.