Doing the same on postgresql_db module seems to work
Is it a problem authenticating as the postgres user?
- name: PostgreSQL | Make sure the PostgreSQL users are present
postgresql_user:
password: "{{item.password | default('pass')}}"
state: present
login_host: "{{item.host | default('localhost')}}"
with_items: postgresql_users
when: postgresql_users|length > 0
# main.yml
- include: users.yml
tags: [postgresql, postgresql-users]
sudo: yes
sudo_user: postgres