---

pgadmin_id: "{{ inventory_hostname }}-pgadmin"

pgadmin4_docker: {
  networks: [
    {
      name: front-tier,
      external: true,
    },
    {
      name: back-tier,
      external: true,
    },
  ],
  volumes: [
    {
      name: pgadmin_data
    },
  ],
  services: [
    {
      name: "{{ pgadmin_id }}",
      image_name: "{{ pgadmin4_image_name }}",
      image_version: "{{ pgadmin4_image_version }}",
      labels: [
        '"traefik.enable=true"',   
        '"traefik.http.routers.{{ pgadmin_id }}.service={{ pgadmin_id }}"',
        '"traefik.http.routers.{{ pgadmin_id }}.rule=Host(`{{ inventory_hostname }}-pgadmin4.{{ domain }}`)"',
        '"traefik.http.routers.{{ pgadmin_id }}.entrypoints=websecure"',
        '"traefik.http.routers.{{ pgadmin_id }}.tls=true"',
        '"traefik.http.routers.{{ pgadmin_id }}.tls.certresolver=letsencrypt"',
        '"traefik.http.services.{{ pgadmin_id }}.loadbalancer.server.port={{ http_port }}"',
      ],
      environment: [
        "PGADMIN_DEFAULT_EMAIL: \"{{ pgadmin4_admin_username }}\"",
        "PGADMIN_DEFAULT_PASSWORD: \"{{ pgadmin4_admin_password }}\"",
        "PGADMIN_CONFIG_CONSOLE_LOG_LEVEL: \"20\"",
      ],
      volumes: [
        '"pgadmin_data:/var/lib/pgadmin"',
      ],
      networks: [
        '"front-tier"',
        '"back-tier"',
      ],
      extra_hosts: "{{ pgadmin_extra_hosts | default([]) }}",
    }
  ],
}