---
- name: Create container volumes
  containers.podman.podman_volume:
    state: present
    name: "{{ database_dir }}"

- name: Create postgres container
  containers.podman.podman_container:
#    name: gitea-pgdb
    name: "{{ app }}-pgdb"
#    user: 1000
    state: quadlet
#    network: gitea-net
    network: "{{ podman_network }}"
    image: docker.io/postgres:latest
    tty: true
    shm_size: 128mb
    volume:
#      - /home/seandersont/gitea_db:/var/lib/postgresql/data
      - "{{ database_dir }}:/var/lib/postgresql/data"
    security_opt: "label=disable"
    env:
      POSTGRES_USER: "{{ app }}"
      POSTGRES_PASSWORD: "mcGdDizPrFFv9SS4c55m"
      POSTGRES_DB: "{{ app }}"

#      POSTGRES_USER: "gitea"
#      POSTGRES_PASSWORD: "MicrophoneExtensionBalb0a"
#      POSTGRES_DB: "gitea"
    quadlet_options:
      - "AutoUpdate=registry"
      - |
        [Install]
        WantedBy=default.target


- name: Start postgres systemd unit
  ansible.builtin.systemd:
    name: "{{ app }}-pgdb"
#    name: gitea-pgdb
    daemon_reload: true
    state: started
    enabled: true
