---
- name: "[PostgreSQL] - PostgreSQL packages are installed"
  ansible.builtin.package:
    name: "{{ pg_deps }}"
    state: "present"
  vars:
    pg_deps:
      - "postgresql"
      - "php{{ php_ver }}-pgsql"
      - "python3-psycopg2"

- name: "[PostgreSQL] - nextcloud role is created."
  postgresql_user:
    name: "{{ nextcloud_db_admin }}"
    password: "{{ nextcloud_db_pwd }}"
    encrypted: true
    state: present
    role_attr_flags: CREATEDB
  become_user: postgres
  become: true

- name: "[PostgreSQL] - nextcloud database is created."
  postgresql_db:
    name: "{{ nextcloud_db_name }}"
    state: present
    owner: "{{ nextcloud_db_admin }}"
  become_user: postgres
  become: true
